@@ -1058,6 +1058,30 @@ free-threaded build and false for the GIL-enabled build. |
1058 | 1058 |
|
1059 | 1059 | (Contributed by Neil Schemenauer and Kumar Aditya in :gh:`130010`.) |
1060 | 1060 |
|
| 1061 | +.. _whatsnew314-incremental-gc: |
| 1062 | + |
| 1063 | +Incremental garbage collection |
| 1064 | +------------------------------ |
| 1065 | + |
| 1066 | +The cycle garbage collector is now incremental. |
| 1067 | +This means that maximum pause times are reduced |
| 1068 | +by an order of magnitude or more for larger heaps. |
| 1069 | + |
| 1070 | +There are now only two generations: young and old. |
| 1071 | +When :func:`gc.collect` is not called directly, the |
| 1072 | +GC is invoked a little less frequently. When invoked, it |
| 1073 | +collects the young generation and an increment of the |
| 1074 | +old generation, instead of collecting one or more generations. |
| 1075 | + |
| 1076 | +The behavior of :func:`!gc.collect` changes slightly: |
| 1077 | + |
| 1078 | +* ``gc.collect(1)``: Performs an increment of garbage collection, |
| 1079 | + rather than collecting generation 1. |
| 1080 | +* Other calls to :func:`!gc.collect` are unchanged. |
| 1081 | + |
| 1082 | +(Contributed by Mark Shannon in :gh:`108362`.) |
| 1083 | + |
| 1084 | + |
1061 | 1085 | Other language changes |
1062 | 1086 | ====================== |
1063 | 1087 |
|
@@ -1486,6 +1510,36 @@ functools |
1486 | 1510 | (Contributed by Sayandip Dutta in :gh:`125916`.) |
1487 | 1511 |
|
1488 | 1512 |
|
| 1513 | +gc |
| 1514 | +-- |
| 1515 | + |
| 1516 | +The cyclic garbage collector is now incremental, |
| 1517 | +which changes the meaning of the results of |
| 1518 | +:meth:`~gc.get_threshold` and :meth:`~gc.set_threshold` |
| 1519 | +as well as :meth:`~gc.get_count` and :meth:`~gc.get_stats`. |
| 1520 | + |
| 1521 | +* For backwards compatibility, :meth:`~gc.get_threshold` continues to return |
| 1522 | + a three-item tuple. |
| 1523 | + The first value is the threshold for young collections, as before; |
| 1524 | + the second value determines the rate at which the old collection is scanned |
| 1525 | + (the default is 10, and higher values mean that the old collection |
| 1526 | + is scanned more slowly). |
| 1527 | + The third value is meaningless and is always zero. |
| 1528 | + |
| 1529 | +* :meth:`~gc.set_threshold` ignores any items after the second. |
| 1530 | + |
| 1531 | +* :meth:`~gc.get_count` and :meth:`~gc.get_stats` continue to return |
| 1532 | + the same format of results. |
| 1533 | + The only difference is that instead of the results referring to |
| 1534 | + the young, aging and old generations, |
| 1535 | + the results refer to the young generation |
| 1536 | + and the aging and collecting spaces of the old generation. |
| 1537 | + |
| 1538 | +In summary, code that attempted to manipulate the behavior of the cycle GC |
| 1539 | +may not work exactly as intended, but it is very unlikely to be harmful. |
| 1540 | +All other code will work just fine. |
| 1541 | + |
| 1542 | + |
1489 | 1543 | getopt |
1490 | 1544 | ------ |
1491 | 1545 |
|
@@ -2233,6 +2287,7 @@ asyncio |
2233 | 2287 | (Contributed by Yury Selivanov, Pablo Galindo Salgado, and Łukasz Langa |
2234 | 2288 | in :gh:`91048`.) |
2235 | 2289 |
|
| 2290 | + |
2236 | 2291 | base64 |
2237 | 2292 | ------ |
2238 | 2293 |
|
@@ -2241,6 +2296,15 @@ base64 |
2241 | 2296 | (Contributed by Bénédikt Tran, Chris Markiewicz, and Adam Turner in :gh:`118761`.) |
2242 | 2297 |
|
2243 | 2298 |
|
| 2299 | +gc |
| 2300 | +-- |
| 2301 | + |
| 2302 | +* The new :ref:`incremental garbage collector <whatsnew314-incremental-gc>` |
| 2303 | + means that maximum pause times are reduced |
| 2304 | + by an order of magnitude or more for larger heaps. |
| 2305 | + (Contributed by Mark Shannon in :gh:`108362`.) |
| 2306 | + |
| 2307 | + |
2244 | 2308 | io |
2245 | 2309 | --- |
2246 | 2310 | * :mod:`io` which provides the built-in :func:`open` makes less system calls |
@@ -2707,6 +2771,13 @@ Changes in the Python API |
2707 | 2771 | Wrap it in :func:`staticmethod` if you want to preserve the old behavior. |
2708 | 2772 | (Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.) |
2709 | 2773 |
|
| 2774 | +* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`, |
| 2775 | + which means that the behavior of :func:`gc.collect` changes slightly: |
| 2776 | + |
| 2777 | + * ``gc.collect(1)``: Performs an increment of garbage collection, |
| 2778 | + rather than collecting generation 1. |
| 2779 | + * Other calls to :func:`!gc.collect` are unchanged. |
| 2780 | + |
2710 | 2781 | * The :func:`locale.nl_langinfo` function now sets temporarily the ``LC_CTYPE`` |
2711 | 2782 | locale in some cases. |
2712 | 2783 | This temporary change affects other threads. |
|