@@ -37,18 +37,11 @@ The :mod:`!gc` module provides the following functions:
3737
3838.. function :: collect(generation=2)
3939
40- Perform a collection. The optional argument *generation *
40+ With no arguments, run a full collection. The optional argument *generation *
4141 may be an integer specifying which generation to collect (from 0 to 2). A
4242 :exc: `ValueError ` is raised if the generation number is invalid. The sum of
4343 collected objects and uncollectable objects is returned.
4444
45- Calling ``gc.collect(0) `` will perform a GC collection on the young generation.
46-
47- Calling ``gc.collect(1) `` will perform a GC collection on the young generation
48- and an increment of the old generation.
49-
50- Calling ``gc.collect(2) `` or ``gc.collect() `` performs a full collection
51-
5245 The free lists maintained for a number of built-in types are cleared
5346 whenever a full collection or collection of the highest generation (2)
5447 is run. Not all items in some free lists may be freed due to the
@@ -57,9 +50,6 @@ The :mod:`!gc` module provides the following functions:
5750 The effect of calling ``gc.collect() `` while the interpreter is already
5851 performing a collection is undefined.
5952
60- .. versionchanged :: 3.14
61- ``generation=1 `` performs an increment of collection.
62-
6353
6454.. function :: set_debug(flags)
6555
@@ -77,18 +67,12 @@ The :mod:`!gc` module provides the following functions:
7767
7868
7969 Returns a list of all objects tracked by the collector, excluding the list
80- returned. If *generation * is not ``None ``, return only the objects as follows:
81-
82- * 0: All objects in the young generation
83- * 1: No objects, as there is no generation 1 (as of Python 3.14)
84- * 2: All objects in the old generation
70+ returned. If *generation * is not ``None ``, return only the objects tracked by
71+ the collector that are in that generation.
8572
8673 .. versionchanged :: 3.8
8774 New *generation * parameter.
8875
89- .. versionchanged :: 3.14
90- Generation 1 is removed
91-
9276 .. audit-event :: gc.get_objects generation gc.get_objects
9377
9478.. function :: get_stats()
@@ -124,33 +108,26 @@ The :mod:`!gc` module provides the following functions:
124108 Set the garbage collection thresholds (the collection frequency). Setting
125109 *threshold0 * to zero disables collection.
126110
127- The GC classifies objects into two generations depending on whether they have
128- survived a collection. New objects are placed in the young generation. If an
129- object survives a collection it is moved into the old generation.
130-
131- In order to decide when to run, the collector keeps track of the number of object
111+ The GC classifies objects into three generations depending on how many
112+ collection sweeps they have survived. New objects are placed in the youngest
113+ generation (generation ``0 ``). If an object survives a collection it is moved
114+ into the next older generation. Since generation ``2 `` is the oldest
115+ generation, objects in that generation remain there after a collection. In
116+ order to decide when to run, the collector keeps track of the number object
132117 allocations and deallocations since the last collection. When the number of
133118 allocations minus the number of deallocations exceeds *threshold0 *, collection
134- starts. For each collection, all the objects in the young generation and some
135- fraction of the old generation is collected.
119+ starts. Initially only generation ``0 `` is examined. If generation ``0 `` has
120+ been examined more than *threshold1 * times since generation ``1 `` has been
121+ examined, then generation ``1 `` is examined as well.
122+ With the third generation, things are a bit more complicated,
123+ see `Garbage collector design <https://devguide.python.org/garbage_collector >`_
124+ for more information.
136125
137126 In the free-threaded build, the increase in process memory usage is also
138- checked before running the collector. If the memory usage has not increased
127+ checked before running the collector. If the memory usage has not increased
139128 by 10% since the last collection and the net number of object allocations
140129 has not exceeded 40 times *threshold0 *, the collection is not run.
141130
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.
146-
147- *threshold2 * is ignored.
148-
149- See `Garbage collector design <https://devguide.python.org/garbage_collector >`_ for more information.
150-
151- .. versionchanged :: 3.14
152- *threshold2 * is ignored
153-
154131
155132.. function :: get_count()
156133
0 commit comments