-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The specific problem here is that there are macros in the Stable ABI that access the ob_refcnt and ob_type directly. This makes it impossible to move those fields or change the meaning of some bits in them.
At some point in the future it would be nice if the macros that access these (mainly Py_INCREF, Py_DECREF and Py_TYPE) were changed into real functions (not inline functions!), so that we can use some bits of these fields for flags. Possible uses include immortality, some GC state, and the nogil branch.
I am creating this issue in order to request feedback on how problematic this would be for current heavy users of the Stable ABI. There's a tradeoff: we'd be able to offer more stability for a one-time change. The cost of the one-time change would be twofold:
- Wheels need to be rebuilt in order to be compatible with the new Stable ABI version.
- Wheels using the Stable ABI would incur extra function call overhead for every
INCREFandDECREFcall (and forPy_TYPE, but I assume that's less of a concern).
This ties in with #39 -- we could arrange things so that 3.13 and several later versions still support the macros (or static inline functions -- for Stable ABI purposes that's pretty much the same thing), but any wheel built with 3.13 using the Stable ABI will use the functions. (You can still build wheels that use the macros, but they won't be compatible with future Python versions. I think this comes down to similar choices you have with HPy.)
My main question is whether this is ever going to be acceptable given the performance degradation due to the function calls. If it isn't, we have to do something else. If the performance hit is acceptable, we can talk about how we would evolve the Stable ABI to switch to function calls with minimal disruption for projects that use it. There would have to be a PEP in that case, I suspect.