diff options
author | Jacob Bower <1978924+jbower-fb@users.noreply.github.com> | 2023-03-14 01:35:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 01:35:54 (GMT) |
commit | cbd3fbfb6e5c1cc96bbeb99483a580f165b01671 (patch) | |
tree | 7e0e0ea4c7dc40b48528702c1c0c32914d9798f7 /Doc/c-api | |
parent | 457e4d1a516c2b83edeff2f255f4cd6e7b114feb (diff) | |
download | cpython-cbd3fbfb6e5c1cc96bbeb99483a580f165b01671.zip cpython-cbd3fbfb6e5c1cc96bbeb99483a580f165b01671.tar.gz cpython-cbd3fbfb6e5c1cc96bbeb99483a580f165b01671.tar.bz2 |
gh-102013: Add PyUnstable_GC_VisitObjects (#102014)
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/gcsupport.rst | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst index 8c90d1e..cb5d64a 100644 --- a/Doc/c-api/gcsupport.rst +++ b/Doc/c-api/gcsupport.rst @@ -228,3 +228,36 @@ garbage collection runs. Returns the current state, 0 for disabled and 1 for enabled. .. versionadded:: 3.10 + + +Querying Garbage Collector State +-------------------------------- + +The C-API provides the following interface for querying information about +the garbage collector. + +.. c:function:: void PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg) + + Run supplied *callback* on all live GC-capable objects. *arg* is passed through to + all invocations of *callback*. + + .. warning:: + If new objects are (de)allocated by the callback it is undefined if they + will be visited. + + Garbage collection is disabled during operation. Explicitly running a collection + in the callback may lead to undefined behaviour e.g. visiting the same objects + multiple times or not at all. + + .. versionadded:: 3.12 + +.. c:type:: int (*gcvisitobjects_t)(PyObject *object, void *arg) + + Type of the visitor function to be passed to :c:func:`PyUnstable_GC_VisitObjects`. + *arg* is the same as the *arg* passed to ``PyUnstable_GC_VisitObjects``. + Return ``0`` to continue iteration, return ``1`` to stop iteration. Other return + values are reserved for now so behavior on returning anything else is undefined. + + .. versionadded:: 3.12 + + |