Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add additional significant optimizations mentioned in the changelog
  • Loading branch information
CAM-Gerlach committed Oct 19, 2022
commit c99b5079952a5a8fc4aa2860f0f7f64f93919ba3
24 changes: 24 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1138,12 +1138,30 @@ Optimizations
fast as a corresponding :term:`f-string` expression.
(Contributed by Serhiy Storchaka in :issue:`28307`.)

* Integer division (``//``) is better tuned for optimization by compilers.
It is now around 20% faster on x86-64 when dividing an :class:`int`
by a value smaller than ``2**30``.
(Contributed by Gregory P. Smith and Tim Peters in :gh:`90564`.)

* :func:`sum` is now nearly 30% faster for integers smaller than ``2**30``.
Copy link
Copy Markdown
Member

@markshannon markshannon Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sum() is still much slower than 2.7.
Maybe we shouldn't mention this, until it is fixed in 3.12

Copy link
Copy Markdown
Member Author

@CAM-Gerlach CAM-Gerlach Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, though on the other hand, it still a fairly substantial improvement over 3.10, the previous feature version, which seems to me is the main focus of this section—at least in the past, I'm not sure optimizations were only mentioned if they exceeded 2.7's speed for something, since that likely wasn't the case for quite a few of them. That said, I'm certainly not the expert here (unlike you all), and will of course defer to the judgement of @pablogsal as RM and you and rest of the core dev performance folks on whether this should be included, if you think its best left out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On discuss - release, Pable said "I don’t think there is anything wrong mentioning that is faster than the version in 3.10. After all there was work here to make the situation better and if true, I don’t see why a considerable improvement over the previous version should not be mentioned". Sum is not new, but since we have an optimization section, I agree.

(Contributed by Stefan Behnel in :gh:`68264`.)

* Resizing lists is streamlined for the common case,
speeding up :meth:`list.append` by ≈15%
and simple :term:`list comprehension`\s by up to 20-30%
(Contributed by Dennis Sweeney in :gh:`91165`.)

* Dictionaries don't store hash values when all keys are Unicode objects,
decreasing :class:`dict` size.
For example, ``sys.getsizeof(dict.fromkeys("abcdefg"))``
is reduced from 352 bytes to 272 bytes (23% smaller) on 64-bit platforms.
(Contributed by Inada Naoki in :issue:`46845`.)

* Using :class:`asyncio.DatagramProtocol` is now orders of magnitude faster
when transferring large files over UDP,
with speeds over 100 times higher for a ≈60 MiB file.
(Contributed by msoxzw in :gh:`91487`.)

* :mod:`math` functions :func:`~math.comb` and :func:`~math.perm` are now
≈10 times faster for large arguments (with a larger speedup for larger *k*).
(Contributed by Serhiy Storchaka in :issue:`37295`.)
Expand All @@ -1154,6 +1172,12 @@ Optimizations
<https://pyperformance.readthedocs.io/benchmarks.html#regex-dna>`_ up to 10%
faster than Python 3.10.

* The :mod:`statistics` functions :func:`~statistics.mean`,
:func:`~statistics.variance` and :func:`~statistics.stdev` now consume
iterators in one pass rather than converting them to a :class:`list` first.
This is twice as fast and can save substantial memory.
(Contributed by Raymond Hettinger in :gh:`90415`.)

* :func:`unicodedata.normalize`
now normalizes pure-ASCII strings in constant time.
(Contributed by Dong-hee Na in :issue:`44987`.)
Expand Down