From 1e118b3325eff5bcd05950a349725dba4f9e750f Mon Sep 17 00:00:00 2001 From: Anandesh Sharma Date: Fri, 27 Feb 2026 04:01:17 +0530 Subject: [PATCH] gh-144960: Clarify GC threshold1 formula in set_threshold docs The documentation stated that the fraction of the old generation scanned is "inversely proportional to threshold1" and that the default value of 10 results in 1% being scanned. However, this was confusing because a naive interpretation of "inversely proportional" (1/threshold1 = 1/10 = 10%) does not match the stated 1%. Clarify by showing the actual formula: 1/(10 * threshold1), which accounts for the internal SCAN_RATE_DIVISOR constant of 10. Co-Authored-By: Claude Opus 4.6 --- Doc/library/gc.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst index 652475886fc30f..6c560d4251b8cb 100644 --- a/Doc/library/gc.rst +++ b/Doc/library/gc.rst @@ -139,10 +139,11 @@ The :mod:`!gc` module provides the following functions: by 10% since the last collection and the net number of object allocations has not exceeded 40 times *threshold0*, the collection is not run. - The fraction of the old generation that is collected is **inversely** proportional - to *threshold1*. The larger *threshold1* is, the slower objects in the old generation - are collected. - For the default value of 10, 1% of the old generation is scanned during each collection. + The fraction of the old generation that is scanned during each collection is + ``1 / (10 * threshold1)``, making it **inversely** proportional to *threshold1*. + The larger *threshold1* is, the slower objects in the old generation are collected. + For the default value of 10, this means approximately 1% of the old generation is + scanned during each collection. *threshold2* is ignored.