Skip to content

Commit a2f9896

Browse files
committed
Retarget incremental GC changes to 3.14
1 parent 67f6e08 commit a2f9896

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

Doc/library/gc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The :mod:`gc` module provides the following functions:
6060
The effect of calling ``gc.collect()`` while the interpreter is already
6161
performing a collection is undefined.
6262

63-
.. versionchanged:: 3.13
63+
.. versionchanged:: 3.14
6464
``generation=1`` performs an increment of collection.
6565

6666

@@ -83,13 +83,13 @@ The :mod:`gc` module provides the following functions:
8383
returned. If *generation* is not ``None``, return only the objects as follows:
8484

8585
* 0: All objects in the young generation
86-
* 1: No objects, as there is no generation 1 (as of Python 3.13)
86+
* 1: No objects, as there is no generation 1 (as of Python 3.14)
8787
* 2: All objects in the old generation
8888

8989
.. versionchanged:: 3.8
9090
New *generation* parameter.
9191

92-
.. versionchanged:: 3.13
92+
.. versionchanged:: 3.14
9393
Generation 1 is removed
9494

9595
.. audit-event:: gc.get_objects generation gc.get_objects
@@ -137,7 +137,7 @@ The :mod:`gc` module provides the following functions:
137137

138138
See `Garbage collector design <https://devguide.python.org/garbage_collector>`_ for more information.
139139

140-
.. versionchanged:: 3.13
140+
.. versionchanged:: 3.14
141141
*threshold2* is ignored
142142

143143

Doc/whatsnew/3.14.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,29 @@ Improved Error Messages
172172
ValueError: too many values to unpack (expected 3, got 4)
173173
174174
175+
.. _whatsnew314-incremental-gc:
176+
177+
Incremental garbage collection
178+
------------------------------
179+
180+
The cycle garbage collector is now incremental.
181+
This means that maximum pause times are reduced
182+
by an order of magnitude or more for larger heaps.
183+
184+
There are now only two generations: young and old.
185+
When :func:`gc.collect` is not called directly, the
186+
GC is invoked a little less frequently. When invoked, it
187+
collects the young generation and an increment of the
188+
old generation, instead of collecting one or more generations.
189+
190+
The behavior of :func:`!gc.collect` changes slightly:
191+
192+
* ``gc.collect(1)``: Performs an increment of garbage collection,
193+
rather than collecting generation 1.
194+
* Other calls to :func:`!gc.collect` are unchanged.
195+
196+
(Contributed by Mark Shannon in :gh:`108362`.)
197+
175198
Other Language Changes
176199
======================
177200

@@ -283,6 +306,35 @@ functools
283306
(Contributed by Dominykas Grigonis in :gh:`119127`.)
284307

285308

309+
gc
310+
--
311+
312+
The cyclic garbage collector is now incremental,
313+
which changes the meaning of the results of
314+
:meth:`~gc.get_threshold` and :meth:`~gc.set_threshold`
315+
as well as :meth:`~gc.get_count` and :meth:`~gc.get_stats`.
316+
317+
* For backwards compatibility, :meth:`~gc.get_threshold` continues to return
318+
a three-item tuple.
319+
The first value is the threshold for young collections, as before;
320+
the second value determines the rate at which the old collection is scanned
321+
(the default is 10, and higher values mean that the old collection
322+
is scanned more slowly).
323+
The third value is meaningless and is always zero.
324+
325+
* :meth:`~gc.set_threshold` ignores any items after the second.
326+
327+
* :meth:`~gc.get_count` and :meth:`~gc.get_stats` continue to return
328+
the same format of results.
329+
The only difference is that instead of the results referring to
330+
the young, aging and old generations,
331+
the results refer to the young generation
332+
and the aging and collecting spaces of the old generation.
333+
334+
In summary, code that attempted to manipulate the behavior of the cycle GC
335+
may not work exactly as intended, but it is very unlikely to be harmful.
336+
All other code will work just fine.
337+
286338
http
287339
----
288340

@@ -415,6 +467,14 @@ asyncio
415467
reduces memory usage.
416468
(Contributed by Kumar Aditya in :gh:`107803`.)
417469

470+
gc
471+
--
472+
473+
* The new :ref:`incremental garbage collector <whatsnew314-incremental-gc>`
474+
means that maximum pause times are reduced
475+
by an order of magnitude or more for larger heaps.
476+
(Contributed by Mark Shannon in :gh:`108362`.)
477+
418478
Deprecated
419479
==========
420480

@@ -617,6 +677,13 @@ Changes in the Python API
617677
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
618678
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)
619679

680+
* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`,
681+
which means that the behavior of :func:`gc.collect` changes slightly:
682+
683+
* ``gc.collect(1)``: Performs an increment of garbage collection,
684+
rather than collecting generation 1.
685+
* Other calls to :func:`!gc.collect` are unchanged.
686+
620687
* The :func:`locale.nl_langinfo` function now sets temporarily the ``LC_CTYPE``
621688
locale in some cases.
622689
This temporary change affects other threads.

0 commit comments

Comments
 (0)