Skip to content

Simplify conversion to and from Python objects#8

Merged
awolverp merged 8 commits intoawolverp:masterfrom
andersk:simplify-conversion
Apr 11, 2026
Merged

Simplify conversion to and from Python objects#8
awolverp merged 8 commits intoawolverp:masterfrom
andersk:simplify-conversion

Conversation

@andersk
Copy link
Copy Markdown
Contributor

@andersk andersk commented Apr 10, 2026

Take advantage of PyO3’s FromPyObject and IntoPyObject traits to save a lot of manual type checking and conversion work. (This changes the TypeError message strings in some cases but the new ones seem fine.)

andersk added 8 commits April 10, 2026 11:33
This efficiently avoids copying the input where possible, while being
simpler and safer.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This also reduces the number of NodeGuard::clone calls.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@awolverp
Copy link
Copy Markdown
Owner

Wow thank you I didn't know about this feature of FromPyObject

@awolverp awolverp merged commit 30ebc3a into awolverp:master Apr 11, 2026
2 checks passed
@andersk andersk deleted the simplify-conversion branch April 14, 2026 22:38
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