◐ Shell
clean mode source ↗

bpo-40241: Add PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public C-API by pablogsal · Pull Request #19461 · python/cpython

Expand Up @@ -60,6 +60,24 @@ Constructors for container types must conform to two rules: followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, usually near the end of the constructor.
.. 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`.
Comment thread

pablogsal marked this conversation as resolved.

.. versionadded:: 3.9

.. 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`.
Comment thread

pablogsal marked this conversation as resolved.

.. versionadded:: 3.9
Similarly, the deallocator for the object must conform to a similar pair of rules: Expand Down