@@ -108,7 +108,7 @@ Interpreter improvements:
108108* :ref: `A new type of interpreter <whatsnew314-tail-call-interpreter >`
109109* :ref: `Free-threaded mode improvements <whatsnew314-free-threaded-cpython >`
110110* :ref: `Improved error messages <whatsnew314-improved-error-messages >`
111- * :ref: `Incremental garbage collection <whatsnew314-incremental-gc >`
111+ * :ref: `Generational garbage collection <whatsnew314-incremental-gc >`
112112
113113Significant improvements in the standard library:
114114
@@ -955,26 +955,22 @@ when a module is imported) will still emit the syntax warning.
955955
956956.. _whatsnew314-incremental-gc :
957957
958- Incremental garbage collection
959- ------------------------------
960-
961- The cycle garbage collector is now incremental.
962- This means that maximum pause times are reduced
963- by an order of magnitude or more for larger heaps.
958+ Generational garbage collection
959+ -------------------------------
964960
965- There are now only two generations: young and old.
966- When :func: `gc.collect ` is not called directly, the
967- GC is invoked a little less frequently. When invoked, it
968- collects the young generation and an increment of the
969- old generation, instead of collecting one or more generations.
961+ The cycle garbage collector uses three generations in the default build:
962+ generation 0, generation 1, and generation 2.
970963
971- The behavior of :func: `!gc.collect ` changes slightly:
964+ The behavior of :func: `!gc.collect ` matches the traditional generational
965+ collector:
972966
973- * ``gc.collect(1 ) ``: Performs an increment of garbage collection,
974- rather than collecting generation 1.
975- * Other calls to :func: ` ! gc.collect` are unchanged .
967+ * ``gc.collect(0 ) ``: Collect generation 0.
968+ * `` gc.collect(1) ``: Collect generations 0 and 1.
969+ * `` gc.collect(2) `` or `` gc.collect() ``: Perform a full collection .
976970
977- (Contributed by Mark Shannon in :gh: `108362 `.)
971+ Likewise, :func: `!gc.get_objects(1) ` returns objects in generation 1, and
972+ :func: `!gc.set_threshold ` and :func: `!gc.get_threshold ` continue to use all
973+ three threshold values.
978974
979975
980976Default interactive shell
@@ -2203,36 +2199,11 @@ difflib
22032199gc
22042200--
22052201
2206- * The new :ref: `incremental garbage collector <whatsnew314-incremental-gc >`
2207- means that maximum pause times are reduced
2208- by an order of magnitude or more for larger heaps.
2209-
2210- Because of this optimization, the meaning of the results of
2211- :meth: `~gc.get_threshold ` and :meth: `~gc.set_threshold ` have changed,
2212- along with :meth: `~gc.get_count ` and :meth: `~gc.get_stats `.
2213-
2214- - For backwards compatibility, :meth: `~gc.get_threshold ` continues to return
2215- a three-item tuple.
2216- The first value is the threshold for young collections, as before;
2217- the second value determines the rate at which the old collection is scanned
2218- (the default is 10, and higher values mean that the old collection
2219- is scanned more slowly).
2220- The third value is now meaningless and is always zero.
2221-
2222- - :meth: `~gc.set_threshold ` now ignores any items after the second.
2223-
2224- - :meth: `~gc.get_count ` and :meth: `~gc.get_stats ` continue to return
2225- the same format of results.
2226- The only difference is that instead of the results referring to
2227- the young, aging and old generations,
2228- the results refer to the young generation
2229- and the aging and collecting spaces of the old generation.
2230-
2231- In summary, code that attempted to manipulate the behavior of the cycle GC
2232- may not work exactly as intended, but it is very unlikely to be harmful.
2233- All other code will work just fine.
2234-
2235- (Contributed by Mark Shannon in :gh: `108362 `.)
2202+ * The :ref: `garbage collector uses three generations <whatsnew314-incremental-gc >`.
2203+ In particular, :func: `gc.collect(1) ` collects generations 0 and 1,
2204+ :func: `gc.get_objects(1) ` returns objects in generation 1, and
2205+ :func: `gc.set_threshold ` and :func: `gc.get_threshold ` continue to use all
2206+ three threshold values.
22362207
22372208
22382209io
@@ -3273,12 +3244,11 @@ Changes in the Python API
32733244 Wrap it in :func: `staticmethod ` if you want to preserve the old behavior.
32743245 (Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh: `121027 `.)
32753246
3276- * The :ref: `garbage collector is now incremental <whatsnew314-incremental-gc >`,
3277- which means that the behavior of :func: `gc.collect ` changes slightly:
3278-
3279- * ``gc.collect(1) ``: Performs an increment of garbage collection,
3280- rather than collecting generation 1.
3281- * Other calls to :func: `!gc.collect ` are unchanged.
3247+ * The :ref: `garbage collector uses three generations <whatsnew314-incremental-gc >`.
3248+ In particular, :func: `gc.collect(1) ` collects generations 0 and 1,
3249+ :func: `gc.get_objects(1) ` returns objects in generation 1, and
3250+ :func: `gc.set_threshold ` and :func: `gc.get_threshold ` continue to use all
3251+ three threshold values.
32823252
32833253* The :func: `locale.nl_langinfo ` function now temporarily sets the ``LC_CTYPE ``
32843254 locale in some cases.
0 commit comments