Skip to content

MNT: Adopt pythoncapi-compat? #26158

@ngoldbaum

Description

@ngoldbaum

As noted in PEP 703, C API functions returning borrowed references are problematic in the nogil build of Python, and new functions are available in Python 3.13 that return new references.

Three years ago @vstinner proposed vendoring pythoncapi-compat to replace npy3k_compat.h in #18713 and that was rejected.

Unlike that proposal, I don't want to expose pythoncapi-compat.h in the public numpy C API, instead I'd only like to use it internally, replacing the internal npy_pycompat.h header. That means concerns raised in that PR about requiring C99 or adding potentially problematic constructs to the numpy C API are moot.

We could also just copy/paste the definitions of the functions I need from the pythoncapi-compat.h header, but I thought it would be worth taking the project's temperature on adding it as a build-time dependency via a submodule like highway and pocketfft, since there will inevitably be other things we want in the future.

Metadata

Metadata

Assignees

Labels

03 - Maintenance39 - free-threadingPRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions