Skip to content

Commit 6100691

Browse files
committed
Add comment about gc.freeze() disabling marking.
1 parent 0090365 commit 6100691

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python/gc_free_threading.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,12 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state,
15221522
process_delayed_frees(interp, state);
15231523

15241524
#ifdef GC_ENABLE_MARK_ALIVE
1525+
// If gc.freeze() was used, it seems likely that doing this "mark alive"
1526+
// pass will not be a performance win. Typically the majority of alive
1527+
// objects will be marked as frozen and will be skipped anyhow, without
1528+
// doing this extra work. Doing this pass also defeats one of the
1529+
// purposes of using freeze: avoiding writes to objects that are frozen.
1530+
// So, we just skip this if gc.freeze() was used.
15251531
if (!state->gcstate->freeze_active) {
15261532
// Mark objects reachable from known roots as "alive". These will
15271533
// be ignored for rest of the GC pass.

0 commit comments

Comments
 (0)