diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-27 14:23:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 14:23:39 (GMT) |
commit | f49a91648aac2ad55b2e005ba28fac1c7edca020 (patch) | |
tree | df68b6205184149246d5b59d3d5f90c099d4127c /Python/gc.c | |
parent | 460ee5b994335994d4b5186c08f44e775b3e55fa (diff) | |
download | cpython-f49a91648aac2ad55b2e005ba28fac1c7edca020.zip cpython-f49a91648aac2ad55b2e005ba28fac1c7edca020.tar.gz cpython-f49a91648aac2ad55b2e005ba28fac1c7edca020.tar.bz2 |
GH-117759: Document incremental GC (GH-123266)
* Update what's new
* Update gc module docs and fix inconsistency in gc.get_objects
Diffstat (limited to 'Python/gc.c')
-rw-r--r-- | Python/gc.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Python/gc.c b/Python/gc.c index 1978c7c..3d36792 100644 --- a/Python/gc.c +++ b/Python/gc.c @@ -1712,20 +1712,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; } } |