Skip to content

Commit 92dc6ab

Browse files
miss-islingtonCAM-Gerlach
authored andcommitted
[3.11] gh-95913: Edit & expand Optimizations in 3.11 WhatsNew (GH-98426) (#98554)
gh-95913: Edit & expand Optimizations in 3.11 WhatsNew (GH-98426) (cherry picked from commit f58631b) Co-authored-by: C.A.M. Gerlach <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent c954335 commit 92dc6ab

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

Doc/whatsnew/3.11.rst

+39-20
Original file line numberDiff line numberDiff line change
@@ -1089,33 +1089,52 @@ fcntl
10891089
Optimizations
10901090
=============
10911091

1092-
* Compiler now optimizes simple C-style formatting with literal format
1093-
containing only format codes ``%s``, ``%r`` and ``%a`` and makes it as
1094-
fast as corresponding f-string expression.
1092+
This section covers specific optimizations independent of the
1093+
:ref:`whatsnew311-faster-cpython` project, which is covered in its own section.
1094+
1095+
* The compiler now optimizes simple
1096+
:ref:`printf-style % formatting <old-string-formatting>` on string literals
1097+
containing only the format codes ``%s``, ``%r`` and ``%a`` and makes it as
1098+
fast as a corresponding :term:`f-string` expression.
10951099
(Contributed by Serhiy Storchaka in :issue:`28307`.)
10961100

1097-
* "Zero-cost" exceptions are implemented. The cost of ``try`` statements is
1098-
almost eliminated when no exception is raised.
1099-
(Contributed by Mark Shannon in :issue:`40222`.)
1101+
* Integer division (``//``) is better tuned for optimization by compilers.
1102+
It is now around 20% faster on x86-64 when dividing an :class:`int`
1103+
by a value smaller than ``2**30``.
1104+
(Contributed by Gregory P. Smith and Tim Peters in :gh:`90564`.)
11001105

1101-
* Pure ASCII strings are now normalized in constant time by :func:`unicodedata.normalize`.
1102-
(Contributed by Dong-hee Na in :issue:`44987`.)
1106+
* :func:`sum` is now nearly 30% faster for integers smaller than ``2**30``.
1107+
(Contributed by Stefan Behnel in :gh:`68264`.)
11031108

1104-
* :mod:`math` functions :func:`~math.comb` and :func:`~math.perm` are now up
1105-
to 10 times or more faster for large arguments (the speed up is larger for
1106-
larger *k*).
1107-
(Contributed by Serhiy Storchaka in :issue:`37295`.)
1109+
* Resizing lists is streamlined for the common case,
1110+
speeding up :meth:`list.append` by ≈15%
1111+
and simple :term:`list comprehension`\s by up to 20-30%
1112+
(Contributed by Dennis Sweeney in :gh:`91165`.)
11081113

1109-
* Dict don't store hash value when all inserted keys are Unicode objects.
1110-
This reduces dict size. For example, ``sys.getsizeof(dict.fromkeys("abcdefg"))``
1111-
becomes 272 bytes from 352 bytes on 64bit platform.
1114+
* Dictionaries don't store hash values when all keys are Unicode objects,
1115+
decreasing :class:`dict` size.
1116+
For example, ``sys.getsizeof(dict.fromkeys("abcdefg"))``
1117+
is reduced from 352 bytes to 272 bytes (23% smaller) on 64-bit platforms.
11121118
(Contributed by Inada Naoki in :issue:`46845`.)
11131119

1114-
* :mod:`re`'s regular expression matching engine has been partially refactored,
1115-
and now uses computed gotos (or "threaded code") on supported platforms. As a
1116-
result, Python 3.11 executes the `pyperformance regular expression benchmarks
1117-
<https://pyperformance.readthedocs.io/benchmarks.html#regex-dna>`_ up to 10%
1118-
faster than Python 3.10.
1120+
* Using :class:`asyncio.DatagramProtocol` is now orders of magnitude faster
1121+
when transferring large files over UDP,
1122+
with speeds over 100 times higher for a ≈60 MiB file.
1123+
(Contributed by msoxzw in :gh:`91487`.)
1124+
1125+
* :mod:`math` functions :func:`~math.comb` and :func:`~math.perm` are now
1126+
≈10 times faster for large arguments (with a larger speedup for larger *k*).
1127+
(Contributed by Serhiy Storchaka in :issue:`37295`.)
1128+
1129+
* The :mod:`statistics` functions :func:`~statistics.mean`,
1130+
:func:`~statistics.variance` and :func:`~statistics.stdev` now consume
1131+
iterators in one pass rather than converting them to a :class:`list` first.
1132+
This is twice as fast and can save substantial memory.
1133+
(Contributed by Raymond Hettinger in :gh:`90415`.)
1134+
1135+
* :func:`unicodedata.normalize`
1136+
now normalizes pure-ASCII strings in constant time.
1137+
(Contributed by Dong-hee Na in :issue:`44987`.)
11191138

11201139

11211140
Faster CPython

0 commit comments

Comments
 (0)