mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-40241: Add PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public C-API (GH-19461)
Add the functions PyObject_GC_IsTracked and PyObject_GC_IsFinalized to the public API to allow to query if Python objects are being currently tracked or have been already finalized by the garbage collector respectively.
This commit is contained in:
parent
0361556537
commit
f13072b8a8
6 changed files with 50 additions and 1 deletions
|
|
@ -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`.
|
||||
|
||||
.. 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`.
|
||||
|
||||
.. versionadded:: 3.9
|
||||
|
||||
Similarly, the deallocator for the object must conform to a similar pair of
|
||||
rules:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue