-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-102013: Add PyUnstable_GC_VisitObjects #102014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
c4a91e0
57edf6d
447bb53
d4f9505
d34a900
7c1fbbb
9b0c461
29f7f88
e16f1e3
024ee30
bd65abb
f03e581
16ea0d6
369e199
219154a
be5b7f0
5752f1c
1512004
87a5b56
295f7dd
ed06dff
620043b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,25 @@ PyAPI_FUNC(int) PyGC_Enable(void); | |
PyAPI_FUNC(int) PyGC_Disable(void); | ||
PyAPI_FUNC(int) PyGC_IsEnabled(void); | ||
|
||
|
||
#if !defined(Py_LIMITED_API) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can put this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not very familiar with the conventions here, is that what we should do with public API (even if it's unstable)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
/* Visit all live GC-capable objects, similar to gc.get_objects(None). The | ||
* supplied callback is called on every such object with the void* arg set | ||
* to the supplied arg. Returning 0 from the callback ends iteration, returning | ||
* 1 allows iteration to continue. Returning any other value may result in | ||
* undefined behaviour. | ||
* | ||
* 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. | ||
jbower-fb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
typedef int (*gcvisitobjects_t)(PyObject*, void*); | ||
PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg); | ||
#endif | ||
|
||
/* Test if a type has a GC head */ | ||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a new (unstable) C-API function for iterating over GC'able objects using a callback: ``PyUnstable_VisitObjects``. |
Uh oh!
There was an error while loading. Please reload this page.