-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[stdlib] Add PyCapsule_New and PyCapsule_GetPointer #4334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
3362d44
to
721af64
Compare
These are critical when interacting with PyCapsules created by other libraries in the system. The current use case is interacting with PyArrow. Signed-off-by: Marius Seritan <[email protected]>
721af64
to
add0db0
Compare
mojo/stdlib/src/python/_cpython.mojo
Outdated
return self.lib.call["PyCapsule_New", PyObjectPtr]( | ||
pointer, name.unsafe_ptr(), destructor | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to call self._inc_total_rc()
here, since PyCapsule_New
returns a new reference. Also, we should cast name
to c_char
, if only to document ABI compliance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, adding.
Could you please put improve the docstring a bit more and add the signature of the Python C API function in a comment #4205 style? |
Signed-off-by: Marius Seritan <[email protected]>
ce7df25
to
fcc2efd
Compare
Nice, I pushed a second commit. I am not sure if you prefer separate commits for ease of review or just one commit for cleaner history. |
I think they get squashed when imported into their internal repo anyway, so it shouldn't matter much. |
Co-authored-by: soraros <[email protected]> Signed-off-by: Marius S <[email protected]>
Co-authored-by: soraros <[email protected]> Signed-off-by: Marius S <[email protected]>
Co-authored-by: soraros <[email protected]> Signed-off-by: Marius S <[email protected]>
Co-authored-by: soraros <[email protected]> Signed-off-by: Marius S <[email protected]>
Co-authored-by: soraros <[email protected]> Signed-off-by: Marius S <[email protected]>
Thanks for the edits, accepted them. |
Signed-off-by: Marius Seritan <[email protected]>
037d990
to
4d41eec
Compare
These are critical when interacting with PyCapsules created by other libraries in the system. The current use case is interacting with PyArrow.