bpo-40241: Add PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public C-API by pablogsal · Pull Request #19461 · python/cpython
.. c:function:: int PyObject_GC_IsTracked(PyObject *op)
Returns 1 if the object type of *op* implements the GC protocol and *op* is being currently tracked by the garbage collector and 0 otherwise.
This is analogous to the Python function :func:`gc.is_tracked`.
pablogsal marked this conversation as resolved.
.. c:function:: int PyObject_GC_IsFinalized(PyObject *op)
Returns 1 if the object type of *op* implements the GC protocol and *op* has been already finalized by the garbage collector and 0 otherwise.
This is analogous to the Python function :func:`gc.is_finalized`.
pablogsal marked this conversation as resolved.
Similarly, the deallocator for the object must conform to a similar pair of rules: