mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] GH-117759: Document incremental GC (GH-123266) (#123395)
GH-117759: Document incremental GC (GH-123266)
* Update what's new
* Update gc module docs and fix inconsistency in gc.get_objects
(cherry picked from commit f49a91648a
)
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
cbcb9e1c0f
commit
aca65112fe
3 changed files with 69 additions and 26 deletions
27
Python/gc.c
27
Python/gc.c
|
@ -1701,20 +1701,25 @@ _PyGC_GetObjects(PyInterpreterState *interp, int generation)
|
|||
GCState *gcstate = &interp->gc;
|
||||
|
||||
PyObject *result = PyList_New(0);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
/* Generation:
|
||||
* -1: Return all objects
|
||||
* 0: All young objects
|
||||
* 1: No objects
|
||||
* 2: All old objects
|
||||
*/
|
||||
if (result == NULL || generation == 1) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (generation == -1) {
|
||||
/* If generation is -1, get all objects from all generations */
|
||||
for (int i = 0; i < NUM_GENERATIONS; i++) {
|
||||
if (append_objects(result, GEN_HEAD(gcstate, i))) {
|
||||
goto error;
|
||||
}
|
||||
if (generation <= 0) {
|
||||
if (append_objects(result, &gcstate->young.head)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (append_objects(result, GEN_HEAD(gcstate, generation))) {
|
||||
if (generation != 0) {
|
||||
if (append_objects(result, &gcstate->old[0].head)) {
|
||||
goto error;
|
||||
}
|
||||
if (append_objects(result, &gcstate->old[1].head)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue