pitrou commented on issue #35531: URL: https://github.com/apache/arrow/issues/35531#issuecomment-1738849940
> There ought to be documentation on how to support both APIs (via duck typing) and any differences between them. E.g. What is a PyCapsule? The APIs based on raw C pointers (`_export_to_c` and `_import_from_c`) are internal APIs, and their use is unsafe: first because they are entirely untyped (the C pointer is passed as a Python integer), second because the exported pointer does not release its pointee when you go out of scope. In other words, a call to `_export_to_c` which is not followed by `_import_from_c` (for example because an exception happened in-between) leaks the exported schema/array. The goal of the PyCapsule-based protocols is to be 1) reasonably type-safe, 2) ensure proper memory deallocation when the PyCapsule goes out of scope. The documentation should probably provide examples of how to deal with the PyCapsule objects: 1) in Cython 2) in pure C. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
