summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-09-02 11:12:16 (GMT)
committerGitHub <noreply@github.com>2024-09-02 11:12:16 (GMT)
commitaca65112fe3e0d2e65a73d98186ac0309a70b65d (patch)
tree3535fdd3e8d2d79af0203dd882742f599295c262 /Python
parentcbcb9e1c0fa332eeab39d51b9abff6e5f00339c7 (diff)
downloadcpython-aca65112fe3e0d2e65a73d98186ac0309a70b65d.zip
cpython-aca65112fe3e0d2e65a73d98186ac0309a70b65d.tar.gz
cpython-aca65112fe3e0d2e65a73d98186ac0309a70b65d.tar.bz2
[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 f49a91648aac2ad55b2e005ba28fac1c7edca020) Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python')
-rw-r--r--Python/gc.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/Python/gc.c b/Python/gc.c
index de24e48..392c527 100644
--- a/Python/gc.c
+++ b/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;
}
}