Initial sketch of a Rust API for CPython#41
Draft
emmatyping wants to merge 1 commit into
Draft
Conversation
This commit introduces a rough sketch of a Rust API for CPython. The overall design goals are 1. Should be very similar to PyO3 API 2. Threadstate should be passed explicitly to ensure safety 3. Should feel familiar to C API users 4. If a C API for something is missing, we can add new internal C APIs (e.g. an operation where we need to pass the threadstate explicitly where it is fetched implicitly from TLS) 5. Should be minimal to what we need, we are not re-implementing all of PyO3 This is still a work in progress so things are still subject to change significantly.
alex
reviewed
Jul 21, 2026
| @@ -0,0 +1,273 @@ | |||
| //! The single raw-call layer. | |||
There was a problem hiding this comment.
FWIW, I think its easy to misread this file as being syscalls (like OS-syscalls). I don't have a particular suggestion, but I think a different name might make more sense.
Author
There was a problem hiding this comment.
Agreed, I will probably rename it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Opening in draft as I plan on iterating on this more, but if people want to take a look and provide feedback I think it is in a state where that would be useful.
This is a rough sketch of a Rust API for CPython. The overall design goals are
This is still a work in progress so things are still subject to change significantly.
I worked with Fable on this initial draft. I will probably iterate from this baseline over the next week.