Repository navigation
ENH: Limited API fallbacks for Py_SETREF and pythoncapi-compat - #32864
prathamhole14 wants to merge 6 commits into
Conversation
|
|
||
| /* | ||
| * TODO: remove when all supported Pythons define these in the Limited API, | ||
| * see https://github.com/capi-workgroup/decisions/issues/110 |
There was a problem hiding this comment.
It looks like pythoncapi-compat doesn't have any support for the limited API. I opened python/pythoncapi-compat#183 to see if there's any possibility of adding that support, which would allow skipping these.
Also why is this in npy_config.h and not npy_pycompat.h? Seems to me it makes more sense in the latter header.
There was a problem hiding this comment.
Thanks!
Every C file gets npy_config.h automatically through npy_common.h. I initially kept it in npy_pycompat.h but then it had to be included by hand so I avoided it because if someone in future uses Py_SETREF they will have to include the header, although it will only fail for LIMITED API builds and CI will inform but something to be considered. Do you prefer I move it npy_pycompat.h?
There was a problem hiding this comment.
Yes, I’d prefer this be moved to the logical spot for this.
|
Update: I added limited C API support to pythoncapi-compat, and I created python/pythoncapi-compat#187 to add Py_SETREF/XSETREF to old limited C API versions. |
PR summary
Part of the Limited API work for
_multiarray_umath.Py_SETREFandPy_XSETREFare written like CPython's own definitionnpy_config.h. This was discussed in ENH: Build_reduction_loop_testsagainst the Limited API #32256 (comment).npy_pycompat.hskippythoncapi-compatwhich does not compile under the Limited API and define the two functions NumPy uses from itPyTuple_FromArrayandPyLong_IsZero.Reverted the hand written use of
Py_SETREF/Py_XSETREFfrom #32256 and 32251.Related to: #31913
AI Disclosure
Wrote the code myself, took help from AI to review the changes made and applied those changes. Took help to write
PyTuple_FromArrayandPyLong_IsZero, most changes were already mentioned in #32256 (comment)Edit: used AI to add
npy_pycompat.hheader to necessary files