Skip to content

feat: add pyo3 feature#446

Open
ParkMyCar wants to merge 2 commits intomainfrom
claude/add-pyo3-feature-7MIKu
Open

feat: add pyo3 feature#446
ParkMyCar wants to merge 2 commits intomainfrom
claude/add-pyo3-feature-7MIKu

Conversation

@ParkMyCar
Copy link
Owner

Try out Claude Code on the web, have it write me a pyo3 feature for compact_str.

Add a new `pyo3` feature that enables seamless conversion between
`CompactString` and Python strings via PyO3. This allows using
`CompactString` in PyO3-based Python extensions.

Implements:
- `FromPyObject` for extracting CompactString from Python strings
- `IntoPyObject` for converting CompactString to Python strings (both owned and borrowed)

Includes:
- Comprehensive test suite covering roundtrips, unicode, inline/heap storage
- Example Python module demonstrating usage in examples/pyo3/
Update to the latest pyo3 version (0.27.2) and adapt to its API changes:
- FromPyObject now takes two lifetime parameters and an Error type
- Use pyo3::Borrowed instead of &Bound for extract method
- Replace deprecated prepare_freethreaded_python() with Python::initialize()
- Replace deprecated Python::with_gil with Python::attach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants