-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MNT: use pythoncapi_compat.h in npy_compat.h #26189
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
Conversation
In the past we used very few macro definitions and that also felt much to use a submodule (and the full file which has a lot of things we don't need). I suspect we still only use a small, but significantly larger, fraction of them all and we have a lot of submodules now anyway. |
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.
Yes, seems a sensible way to go. I guess eventually the submodule will disappear again, once borrowed references are a thing of the past? And that any actual changes in the code to use new routines that give new references will be done in follow-up?
p.s. I had to do a bit of a double-take since you seemed to remove the usage of the headers that you were introducing, but that just meant I should have read your comments better...
Maybe but I don’t see the CPython C API remaining static after the nogil effort over the next few years, and this way we don’t need to maintain our own compatibility shims. I also like these shims because their names match the upstream names so they don’t need another migration in the future to get rid of them besides removing the compat header include. |
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.
This LGTM overall, thanks @ngoldbaum. _core/src/common
seems like the right place to put this. I have one suggestion to avoid contributors being puzzled after a git pull
and missing the submodule - add this near the top of numpy/_core/meson.build
:
if not fs.exists('src/common/pythoncapi-compat')
error('Missing the `pythoncapi-compat` git submodule! Run `git submodule update --init` to fix this.')
endif
There are a couple of other checks like that already, like for svml
and highway
.
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.
Reviewers seem happy and CI seems happy, so let's give it a go:) Thanks Nathan, all!
Following on from #26158 and #26159, this adds a new submodule for
pythoncapi_compat.h
and includes it innpy_pycompat.h
. I also removed all the spots wherenpy_pycompat.h
was getting included unnecessarily, probably leftovers from the python 2->3 migrations.This doesn't actually use the new header yet, that will come in followups.