Skip to content

Commit cbde052

Browse files
committed
gh-105387: Limited C API implements Py_INCREF() as func
In the limited C API version 3.12 and newer, Py_INCREF() and Py_DECREF() functions are now implemented as opaque function calls in the stable ABI to hide implementation details.
1 parent 0cb6b9b commit cbde052

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Include/object.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,9 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);
610610

611611
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
612612
{
613-
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
614-
// Stable ABI for Python built in debug mode
613+
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
614+
// Stable ABI implements Py_INCREF() as a function call on limited C API
615+
// version 3.12 and newer, and on Python built in debug mode
615616
_Py_IncRef(op);
616617
#else
617618
// Non-limited C API and limited C API for Python 3.9 and older access
@@ -641,8 +642,9 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
641642
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
642643
#endif
643644

644-
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API)
645-
// Stable ABI for Python built in debug mode
645+
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
646+
// Stable ABI implements Py_DECREF() as a function call on limited C API
647+
// version 3.12 and newer, and on Python built in debug mode
646648
static inline void Py_DECREF(PyObject *op) {
647649
_Py_DecRef(op);
648650
}

0 commit comments

Comments
 (0)