Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions Include/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,12 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);

static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
{
#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))) \
|| defined(_Py_OPAQUE_PYOBJECT)
// Stable ABI implements Py_INCREF() as a function call on limited C API
// version 3.12 and newer, abi3t, and on Python built in debug mode.
// _Py_IncRef() was added to Python 3.10.0a7, use Py_IncRef() on older versions.
// Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't.
# if Py_LIMITED_API+0 >= 0x030a00A7
#if defined(Py_LIMITED_API) || defined(_Py_OPAQUE_PYOBJECT)
// Since Python 3.16, the stable ABI implements Py_INCREF() as a function
// call on all limited C API versions. _Py_IncRef() was added to Python
// 3.10.0a7, use Py_IncRef() on older versions. Py_IncRef() accepts NULL,
// whereas _Py_IncRef() doesn't.
# if Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10)
_Py_IncRef(op);
# else
Py_IncRef(op);
Expand Down Expand Up @@ -324,14 +323,13 @@ PyAPI_FUNC(void) _Py_MergeZeroLocalRefcount(PyObject *);
#endif // Py_GIL_DISABLED
#endif // Py_LIMITED_API

#if (defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))) \
|| defined(_Py_OPAQUE_PYOBJECT)
// Stable ABI implements Py_DECREF() as a function call on limited C API
// version 3.12 and newer, abi3t, and on Python built in debug mode.
// _Py_DecRef() was added to Python 3.10.0a7, use Py_DecRef() on older versions.
// Py_DecRef() accepts NULL whereas _Py_DecRef() doesn't.
#if defined(Py_LIMITED_API) || defined(_Py_OPAQUE_PYOBJECT)
// Since Python 3.16, the stable ABI implements Py_DECREF() as a function call
// on all limited C API version. _Py_DecRef() was added to Python 3.10.0a7,
// use Py_DecRef() on older versions. Py_DecRef() accepts NULL, whereas
// _Py_DecRef() doesn't.
static inline void Py_DECREF(PyObject *op) {
# if Py_LIMITED_API+0 >= 0x030a00A7
# if Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10)
_Py_DecRef(op);
# else
Py_DecRef(op);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:c:func:`Py_INCREF`, :c:func:`Py_XINCREF`, :c:func:`Py_DECREF` and
:c:func:`Py_XDECREF` are now implemented as function calls on all limited C
API versions. Previously, they were only implemented as function calls on
the limited C API version 3.12 or newer. Patch by Victor Stinner:
Loading