From 722a0cb7f80013c3baab165782fa93e2dd98a116 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sun, 16 Oct 2022 14:24:51 -0500 Subject: [PATCH 1/4] Add line breaks & ref targets to Whatsnew to prepare for future changes --- Doc/whatsnew/3.11.rst | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 56a35f4e4802ba..7c94831c23ace1 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -545,6 +545,8 @@ New Modules (Contributed by Sebastian Rittau in :issue:`42012`.) +.. _whatsnew311-improved-modules: + Improved Modules ================ @@ -1077,6 +1079,8 @@ fcntl the ``FD_CLOEXEC`` flag in addition. +.. _whatsnew311-optimizations: + Optimizations ============= @@ -1109,6 +1113,8 @@ Optimizations faster than Python 3.10. +.. _whatsnew311-faster-cpython: + Faster CPython ============== @@ -1121,9 +1127,14 @@ could be up to 10-60% faster. This project focuses on two major areas in Python: faster startup and faster runtime. Other optimizations not under this project are listed in `Optimizations`_. + +.. _whatsnew311-faster-startup: + Faster Startup -------------- +.. _whatsnew311-faster-imports: + Frozen imports / Static code objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1150,11 +1161,16 @@ impact for short-running programs using Python. (Contributed by Eric Snow, Guido van Rossum and Kumar Aditya in numerous issues.) +.. _whatsnew311-faster-runtime: + Faster Runtime -------------- +.. _whatsnew311-lazy-python-frames: + Cheaper, lazy Python frames ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Python frames are created whenever Python calls a Python function. This frame holds execution information. The following are new frame optimizations: @@ -1171,10 +1187,13 @@ up significantly. We measured a 3-7% speedup in pyperformance. (Contributed by Mark Shannon in :issue:`44590`.) + .. _inline-calls: +.. _whatsnew311-inline-calls: Inlined Python function calls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + During a Python function call, Python will call an evaluating C function to interpret that function's code. This effectively limits pure Python recursion to what's safe for the C stack. @@ -1191,8 +1210,12 @@ We measured a 1-3% improvement in pyperformance. (Contributed by Pablo Galindo and Mark Shannon in :issue:`45256`.) + +.. _whatsnew311-pep659: + PEP 659: Specializing Adaptive Interpreter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + :pep:`659` is one of the key parts of the faster CPython project. The general idea is that while Python is a dynamic language, most code has regions where objects and types rarely change. This concept is known as *type stability*. @@ -1274,6 +1297,8 @@ Bucher, with additional help from Irit Katriel and Dennis Sweeney.) be sped up by :issue:`45947`. +.. _whatsnew311-faster-cpython-misc: + Misc ---- @@ -1285,6 +1310,9 @@ Misc time required for catching an exception by about 10%. (Contributed by Irit Katriel in :issue:`45711`.) + +.. _whatsnew311-faster-cpython-faq: + FAQ --- @@ -1319,6 +1347,8 @@ FAQ | A: No. We're still exploring other optimizations. +.. _whatsnew311-faster-cpython-about: + About ----- @@ -1328,6 +1358,8 @@ funded by Bloomberg LP to work on the project part-time. Finally, many contributors are volunteers from the community. +.. _whatsnew311-bytecode-changes: + CPython bytecode changes ======================== @@ -1384,6 +1416,9 @@ CPython bytecode changes * :opcode:`RESUME` has been added. It is a no-op. Performs internal tracing, debugging and optimization checks. + +.. _whatsnew311-deprecated: + Deprecated ========== @@ -1525,6 +1560,8 @@ Deprecated (Contributed by Serhiy Storchaka and Miro Hrončok in :gh:`92728`.) +.. _whatsnew311-pending-removal-312: + Pending Removal in Python 3.12 ============================== @@ -1580,6 +1617,8 @@ C API: * :c:func:`PyUnicode_InternImmortal()` +.. _whatsnew311-removed: + Removed ======= @@ -1671,6 +1710,9 @@ Removed of ``Tools/scripts`` and is `being developed independently `_ from the Python source tree. + +.. _whatsnew311-porting: + Porting to Python 3.11 ====================== @@ -1678,6 +1720,8 @@ This section lists previously described changes and other bugfixes that may require changes to your code. +.. _whatsnew311-porting-python-api: + Changes in the Python API ------------------------- @@ -1728,6 +1772,9 @@ Changes in the Python API as meaningless when read. To get the pointer to the object's dictionary call :c:func:`PyObject_GenericGetDict` instead. + +.. _whatsnew311-build-changes: + Build Changes ============= @@ -1815,9 +1862,13 @@ Build Changes (Contributed by Serhiy Storchaka in :issue:`46996`.) +.. _whatsnew311-c-api: + C API Changes ============= +.. _whatsnew311-c-api-new-features: + New Features ------------ @@ -1881,6 +1932,9 @@ New Features * Added the :c:member:`PyConfig.safe_path` member. (Contributed by Victor Stinner in :gh:`57684`.) + +.. _whatsnew311-c-api-porting: + Porting to Python 3.11 ---------------------- @@ -2167,6 +2221,9 @@ Porting to Python 3.11 paths and then modify them, finish initialization and use :c:func:`PySys_GetObject` to retrieve :data:`sys.path` as a Python list object and modify it directly. + +.. _whatsnew311-c-api-deprecated: + Deprecated ---------- @@ -2192,6 +2249,9 @@ Deprecated * Deprecate the ``ob_shash`` member of the :c:type:`PyBytesObject`. Use :c:func:`PyObject_Hash` instead. (Contributed by Inada Naoki in :issue:`46864`.) + +.. _whatsnew311-c-api-removed: + Removed ------- From 3ed88724961a938978f44a6b6ac9de7cc21d5a05 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sun, 16 Oct 2022 14:32:14 -0500 Subject: [PATCH 2/4] Use standard heading underbar symbols for H4 sections --- Doc/whatsnew/3.11.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 7c94831c23ace1..d6facab947f80a 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1136,7 +1136,7 @@ Faster Startup .. _whatsnew311-faster-imports: Frozen imports / Static code objects -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Python caches bytecode in the :ref:`__pycache__` directory to speed up module loading. @@ -1169,7 +1169,7 @@ Faster Runtime .. _whatsnew311-lazy-python-frames: Cheaper, lazy Python frames -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^ Python frames are created whenever Python calls a Python function. This frame holds execution information. The following are new frame optimizations: @@ -1192,7 +1192,7 @@ up significantly. We measured a 3-7% speedup in pyperformance. .. _whatsnew311-inline-calls: Inlined Python function calls -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ During a Python function call, Python will call an evaluating C function to interpret that function's code. This effectively limits pure Python recursion to @@ -1214,7 +1214,7 @@ We measured a 1-3% improvement in pyperformance. .. _whatsnew311-pep659: PEP 659: Specializing Adaptive Interpreter -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :pep:`659` is one of the key parts of the faster CPython project. The general idea is that while Python is a dynamic language, most code has regions where From 5b82416bb6bfc1b8a7d85dd16c8cfbd5294ec3f7 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sun, 16 Oct 2022 15:15:07 -0500 Subject: [PATCH 3/4] Flatten Porting subsection; clarify scope of/link Python->CAPI sections --- Doc/whatsnew/3.11.rst | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index d6facab947f80a..acde3ee1eb1c15 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1418,10 +1418,15 @@ CPython bytecode changes .. _whatsnew311-deprecated: +.. _whatsnew311-python-api-deprecated: Deprecated ========== +This section lists Python APIs that have been deprecated in Python 3.11. + +Deprecated C APIs are :ref:`listed separately `. + * Chaining :class:`classmethod` descriptors (introduced in :issue:`19072`) is now deprecated. It can no longer be used to wrap other descriptors such as :class:`property`. The core design of this feature was flawed @@ -1618,10 +1623,15 @@ C API: .. _whatsnew311-removed: +.. _whatsnew311-python-api-removed: Removed ======= +This section lists Python APIs that have been removed in Python 3.12. + +Removed C APIs are :ref:`listed separately `. + * :class:`smtpd.MailmanProxy` is now removed as it is unusable without an external module, ``mailman``. (Contributed by Dong-hee Na in :issue:`35800`.) @@ -1712,18 +1722,16 @@ Removed .. _whatsnew311-porting: +.. _whatsnew311-python-api-porting: Porting to Python 3.11 ====================== This section lists previously described changes and other bugfixes -that may require changes to your code. - - -.. _whatsnew311-porting-python-api: +in the Python API that may require changes to your Python code. -Changes in the Python API -------------------------- +Porting notes for the C API are +:ref:`listed separately `. * Prohibited passing non-:class:`concurrent.futures.ThreadPoolExecutor` executors to :meth:`loop.set_default_executor` following a deprecation in From 54c9b4edbd64dfd54457bde73181cc9cba984ebb Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Sun, 16 Oct 2022 15:38:20 -0500 Subject: [PATCH 4/4] Move C API pending deprecations to C API section, to match the others --- Doc/whatsnew/3.11.rst | 53 +++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index acde3ee1eb1c15..37cd6022b85382 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -1565,15 +1565,17 @@ Deprecated C APIs are :ref:`listed separately `. (Contributed by Serhiy Storchaka and Miro Hrončok in :gh:`92728`.) -.. _whatsnew311-pending-removal-312: +.. _whatsnew311-pending-removal: +.. _whatsnew311-python-api-pending-removal: Pending Removal in Python 3.12 ============================== -The following APIs have been deprecated in earlier Python releases, +The following Python APIs have been deprecated in earlier Python releases, and will be removed in Python 3.12. -Python API: +C APIs pending removal are +:ref:`listed separately `. * :class:`pkgutil.ImpImporter` * :class:`pkgutil.ImpLoader` @@ -1602,25 +1604,6 @@ Python API: * :func:`sqlite3.OptimizedUnicode` * :func:`sqlite3.enable_shared_cache` -C API: - -* :c:func:`PyUnicode_AS_DATA` -* :c:func:`PyUnicode_AS_UNICODE` -* :c:func:`PyUnicode_AsUnicodeAndSize` -* :c:func:`PyUnicode_AsUnicode` -* :c:func:`PyUnicode_FromUnicode` -* :c:func:`PyUnicode_GET_DATA_SIZE` -* :c:func:`PyUnicode_GET_SIZE` -* :c:func:`PyUnicode_GetSize` -* :c:func:`PyUnicode_IS_COMPACT` -* :c:func:`PyUnicode_IS_READY` -* :c:func:`PyUnicode_READY` -* :c:func:`Py_UNICODE_WSTR_LENGTH` -* :c:func:`_PyUnicode_AsUnicode` -* :c:macro:`PyUnicode_WCHAR_KIND` -* :c:type:`PyUnicodeObject` -* :c:func:`PyUnicode_InternImmortal()` - .. _whatsnew311-removed: .. _whatsnew311-python-api-removed: @@ -2258,6 +2241,32 @@ Deprecated (Contributed by Inada Naoki in :issue:`46864`.) +.. _whatsnew311-c-api-pending-removal: + +Pending Removal in Python 3.12 +------------------------------ + +The following C APIs have been deprecated in earlier Python releases, +and will be removed in Python 3.12. + +* :c:func:`PyUnicode_AS_DATA` +* :c:func:`PyUnicode_AS_UNICODE` +* :c:func:`PyUnicode_AsUnicodeAndSize` +* :c:func:`PyUnicode_AsUnicode` +* :c:func:`PyUnicode_FromUnicode` +* :c:func:`PyUnicode_GET_DATA_SIZE` +* :c:func:`PyUnicode_GET_SIZE` +* :c:func:`PyUnicode_GetSize` +* :c:func:`PyUnicode_IS_COMPACT` +* :c:func:`PyUnicode_IS_READY` +* :c:func:`PyUnicode_READY` +* :c:func:`Py_UNICODE_WSTR_LENGTH` +* :c:func:`_PyUnicode_AsUnicode` +* :c:macro:`PyUnicode_WCHAR_KIND` +* :c:type:`PyUnicodeObject` +* :c:func:`PyUnicode_InternImmortal()` + + .. _whatsnew311-c-api-removed: Removed