You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C API] Make Py_REFCNT() opaque in limited C API 3.14 #124127
In the limited C API 3.14 and newer, I propose to change Py_REFCNT() implementation to an opaque function call to hide implementation details. I made a similar change for Py_INCREF() and Py_DECREF() in Python 3.12.
The problem is that with Free Threading (PEP 703), the implementation of this functions becomes less trivial than just getting the object member PyObject.ob_refcnt:
_Py_atomic_load_uint32_relaxed() and _Py_atomic_load_ssize_relaxed() must now be called. But I would prefer to not "leak" such implementation detail into the limited C API.
Activity
pythongh-124127: Make Py_REFCNT() opaque in limited C API 3.14
pythongh-124127: Make Py_REFCNT() opaque in limited C API 3.14
pythongh-124127: Make Py_REFCNT() opaque in limited C API 3.14
pythongh-124127: Make Py_REFCNT() opaque in limited C API 3.14
vstinner commentedon Sep 16, 2024
Previous issue about Py_TYPE(): #120600
gh-124127: Make Py_REFCNT() opaque in limited C API 3.14 (#124128)
vstinner commentedon Sep 24, 2024
Implemented in 9d344fa.
vstinner commentedon Sep 24, 2024
Functions implemented as opaque function calls in limited C API 3.14:
Py_SET_TYPE() is not implemented as an opaque function call since it should not be used in the limited C API, it's only useful with static types.