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

Many NumPy functions marked as needing GIL that do not #2663

Open
jakirkham opened this Issue Oct 16, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@jakirkham
Contributor

jakirkham commented Oct 16, 2018

Recently reached for PyArray_GetPtr, to get quick C level access into a location in a NumPy array. Went to release the GIL as this function does not create any Python objects, but was surprised to find that Cython requires the GIL for it. Started to make a PR, but quickly discovered there are many such functions like PyArray_NDIM, PyArray_STRIDES, PyArray_DATA, etc. that are also marked as requiring the GIL even though they are providing convenient access to struct members. Given the scope and the discussion in issue ( numpy/numpy#11803 ), figured we should discuss the right way forward.

@scoder

This comment has been minimized.

Contributor

scoder commented Oct 16, 2018

AFAICT, these functions/macros are not documented as not requiring the GIL. I'd rather not take that decision on our side. If the NumPy devs agree that they want to support GIL-free access to them in the future, then we can adapt to that in Cython. One more reason to let NumPy ship its own declarations for Cython code.

@jakirkham

This comment has been minimized.

Contributor

jakirkham commented Oct 16, 2018

My understanding is the array structure and data access macros/functions are all safe to use without the GIL. Skimming the associated code seems to confirm this. Though I must admit I don't see any documentation to confirm this belief.

Certainly understand the value in being safe. Also agree this is a pretty reasonable argument for moving the API over to NumPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment