| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1171,33 +1171,52 @@ fcntl | |||
| 1171 | 1171 | Optimizations | |
| 1172 | 1172 | ============= | |
| 1173 | 1173 | ||
| 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. | ||
| 1177 | 1181 | (Contributed by Serhiy Storchaka in :issue:`28307`.) | |
| 1178 | 1182 | ||
| 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`.) | ||
| 1182 | 1187 | ||
| 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`.) | ||
| 1185 | 1190 | ||
| 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`.) | ||
| 1190 | 1195 | ||
| 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. | ||
| 1194 | 1200 | (Contributed by Inada Naoki in :issue:`46845`.) | |
| 1195 | 1201 | ||
| 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`.) | ||
| 1201 | 1220 | ||
| 1202 | 1221 | ||
| 1203 | 1222 | .. _whatsnew311-faster-cpython: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments