@@ -1171,33 +1171,52 @@ fcntl
11711171Optimizations
11721172=============
11731173
1174- * Compiler now optimizes simple C-style formatting with literal format
1175- containing only format codes ``%s ``, ``%r `` and ``%a `` and makes it as
1176- fast as corresponding f-string expression.
1174+ This section covers specific optimizations independent of the
1175+ :ref: `whatsnew311-faster-cpython ` project, which is covered in its own section.
1176+
1177+ * The compiler now optimizes simple
1178+ :ref: `printf-style % formatting <old-string-formatting >` on string literals
1179+ containing only the format codes ``%s ``, ``%r `` and ``%a `` and makes it as
1180+ fast as a corresponding :term: `f-string ` expression.
11771181 (Contributed by Serhiy Storchaka in :issue: `28307 `.)
11781182
1179- * "Zero-cost" exceptions are implemented. The cost of ``try `` statements is
1180- almost eliminated when no exception is raised.
1181- (Contributed by Mark Shannon in :issue: `40222 `.)
1183+ * Integer division (``// ``) is better tuned for optimization by compilers.
1184+ It is now around 20% faster on x86-64 when dividing an :class: `int `
1185+ by a value smaller than ``2**30 ``.
1186+ (Contributed by Gregory P. Smith and Tim Peters in :gh: `90564 `.)
11821187
1183- * Pure ASCII strings are now normalized in constant time by :func: ` unicodedata.normalize `.
1184- (Contributed by Dong-hee Na in :issue: ` 44987 `.)
1188+ * :func: ` sum ` is now nearly 30% faster for integers smaller than `` 2**30 ` `.
1189+ (Contributed by Stefan Behnel in :gh: ` 68264 `.)
11851190
1186- * :mod: ` math ` functions :func: ` ~math.comb ` and :func: ` ~math.perm ` are now up
1187- to 10 times or more faster for large arguments (the speed up is larger for
1188- larger * k *).
1189- (Contributed by Serhiy Storchaka in :issue: ` 37295 `.)
1191+ * Resizing lists is streamlined for the common case,
1192+ speeding up :meth: ` list.append ` by ≈15%
1193+ and simple :term: ` list comprehension ` \s by up to 20-30%
1194+ (Contributed by Dennis Sweeney in :gh: ` 91165 `.)
11901195
1191- * Dict don't store hash value when all inserted keys are Unicode objects.
1192- This reduces dict size. For example, ``sys.getsizeof(dict.fromkeys("abcdefg")) ``
1193- becomes 272 bytes from 352 bytes on 64bit platform.
1196+ * Dictionaries don't store hash values when all keys are Unicode objects,
1197+ decreasing :class: `dict ` size.
1198+ For example, ``sys.getsizeof(dict.fromkeys("abcdefg")) ``
1199+ is reduced from 352 bytes to 272 bytes (23% smaller) on 64-bit platforms.
11941200 (Contributed by Inada Naoki in :issue: `46845 `.)
11951201
1196- * :mod: `re `'s regular expression matching engine has been partially refactored,
1197- and now uses computed gotos (or "threaded code") on supported platforms. As a
1198- result, Python 3.11 executes the `pyperformance regular expression benchmarks
1199- <https://pyperformance.readthedocs.io/benchmarks.html#regex-dna> `_ up to 10%
1200- faster than Python 3.10.
1202+ * Using :class: `asyncio.DatagramProtocol ` is now orders of magnitude faster
1203+ when transferring large files over UDP,
1204+ with speeds over 100 times higher for a ≈60 MiB file.
1205+ (Contributed by msoxzw in :gh: `91487 `.)
1206+
1207+ * :mod: `math ` functions :func: `~math.comb ` and :func: `~math.perm ` are now
1208+ ≈10 times faster for large arguments (with a larger speedup for larger *k *).
1209+ (Contributed by Serhiy Storchaka in :issue: `37295 `.)
1210+
1211+ * The :mod: `statistics ` functions :func: `~statistics.mean `,
1212+ :func: `~statistics.variance ` and :func: `~statistics.stdev ` now consume
1213+ iterators in one pass rather than converting them to a :class: `list ` first.
1214+ This is twice as fast and can save substantial memory.
1215+ (Contributed by Raymond Hettinger in :gh: `90415 `.)
1216+
1217+ * :func: `unicodedata.normalize `
1218+ now normalizes pure-ASCII strings in constant time.
1219+ (Contributed by Dong-hee Na in :issue: `44987 `.)
12011220
12021221
12031222.. _whatsnew311-faster-cpython :
0 commit comments