Skip to content

Commit 1e118b3

Browse files
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 <noreply@anthropic.com>
1 parent f3a381e commit 1e118b3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/library/gc.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ The :mod:`!gc` module provides the following functions:
139139
by 10% since the last collection and the net number of object allocations
140140
has not exceeded 40 times *threshold0*, the collection is not run.
141141

142-
The fraction of the old generation that is collected is **inversely** proportional
143-
to *threshold1*. The larger *threshold1* is, the slower objects in the old generation
144-
are collected.
145-
For the default value of 10, 1% of the old generation is scanned during each collection.
142+
The fraction of the old generation that is scanned during each collection is
143+
``1 / (10 * threshold1)``, making it **inversely** proportional to *threshold1*.
144+
The larger *threshold1* is, the slower objects in the old generation are collected.
145+
For the default value of 10, this means approximately 1% of the old generation is
146+
scanned during each collection.
146147

147148
*threshold2* is ignored.
148149

0 commit comments

Comments
 (0)