Skip to content

Commit

Permalink
pythongh-105387: Limited C API implements Py_INCREF() as func
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vstinner committed Jun 6, 2023
1 parent 0cb6b9b commit cbde052
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,9 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *);

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

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

0 comments on commit cbde052

Please sign in to comment.