Migrate Vector component from ctypes to SWIG bindings with backward compatibility #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the first step in gradually migrating graphserver's hand-made Python bindings from ctypes to SWIG, starting with the Vector component. The migration maintains 100% backward compatibility while establishing a pattern for future component migrations.
Problem
The current Python bindings use hand-crafted ctypes wrappers that are:
Solution
Implemented a hybrid approach that uses SWIG internally while preserving the ctypes interface:
Key Changes
1. SWIG Interface Definition (
core/vector.i
)2. SWIG Vector Wrapper (
pygs/graphserver/vector_swig.py
)3. Hybrid Vector Class (
pygs/graphserver/vector.py
)4. Build System Updates
pyproject.toml
setup.py
for SWIG extension building.gitignore
for SWIG-generated filesExample Usage
Benefits
Testing
Future Work
This establishes the migration pattern for other components:
The hybrid approach allows incremental migration while maintaining system stability throughout the process.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.