dorodo0721 commented on issue #31597: URL: https://github.com/apache/arrow/issues/31597#issuecomment-7309853893
I completed a static audit of the `nogil` declarations in `python/pyarrow/includes/libarrow_python.pxd`. The issue appears to cover more than the examples listed in the recent comment. **Interfaces that appear to require the GIL** `PyFloat_FromHalf`, `NumPyDtypeToArrow`, `NdarrayToArrow`, `NdarrayToTensor`, `TensorToNdarray`, the `Sparse*ToNdarray` and `NdarraysToSparse*` conversion functions, the Pandas conversion functions, `PyBuffer.FromPyObject`, `PyForeignBuffer.Make`, the `PyReadableFile` and `PyOutputStream` constructors, and `TzinfoToString`/`StringToTzinfo` use Python or NumPy APIs, access Python objects, or manipulate Python references. `ConvertPySequence` also appears to belong in this group, and it is specifically mentioned in the issue discussion. Its implementation acquires the GIL internally with `PyAcquireGIL`, so its declaration and call contract need particular care. I found one direct call-site conflict. `NdarrayToArrow` is called inside a `with nogil` block in `python/pyarrow/array.pxi`, while its implementation uses Python and NumPy APIs. If its declaration is changed to require the GIL, that call site will also need to be updated. **Interfaces that appear safe to keep `nogil`** `GetPrimitiveType`, `TensorToSparse*`, and the numeric `TimePoint` conversions appear to perform ordinary C++ data operations without accessing Python objects or calling Python APIs. **Uncertain** `PyDateTime_to_TimePoint` reads fields from a CPython datetime object using macros. It does not appear to call Python functions or execute callbacks, but it still accesses a Python object. My tentative approach would be to require the GIL unless the project’s conventions or maintainers confirm that this direct read is safe without it. This is a source-level audit only. I have not completed Cython generation, a PyArrow build, or the relevant tests. -- 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]
