How to get reference count of a PyObject
from C++?
There are functions Py_INCREF
and Py_DECREF
which increase/decrease it, but I haven't found any function which return object's reference count.
I need it for debugging purposes.
How to get reference count of a PyObject
from C++?
There are functions Py_INCREF
and Py_DECREF
which increase/decrease it, but I haven't found any function which return object's reference count.
I need it for debugging purposes.
The reference count of each and every object is stored in the
PyObject
itself, in a variable calledob_refcnt
. You can directly access that.Alternatively, you can use the
Py_REFCNT
Macro.