Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
Cpython
Commits
f58631be
Unverified
Commit
f58631be
authored
Oct 22, 2022
by
C.A.M. Gerlach
Committed by
GitHub
Oct 22, 2022
Browse files
Options
Downloads
Patches
Plain Diff
gh-95913: Edit & expand Optimizations in 3.11 WhatsNew (#98426)
parent
8f30267a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Doc/whatsnew/3.11.rst
+39
-20
39 additions, 20 deletions
Doc/whatsnew/3.11.rst
with
39 additions
and
20 deletions
Doc/whatsnew/3.11.rst
+
39
−
20
View file @
f58631be
...
...
@@ -1171,33 +1171,52 @@ fcntl
Optimizations
=============
* Compiler now optimizes simple C-style formatting with literal format
containing only format codes ``%s``, ``%r`` and ``%a`` and makes it as
fast as corresponding f-string expression.
This section covers specific optimizations independent of the
:ref:`whatsnew311-faster-cpython` project, which is covered in its own section.
* The compiler now optimizes simple
:ref:`printf-style % formatting <old-string-formatting>` on string literals
containing only the format codes ``%s``, ``%r`` and ``%a`` and makes it as
fast as a corresponding :term:`f-string` expression.
(Contributed by Serhiy Storchaka in :issue:`28307`.)
* "Zero-cost" exceptions are implemented. The cost of ``try`` statements is
almost eliminated when no exception is raised.
(Contributed by Mark Shannon in :issue:`40222`.)
* 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`.)
*
Pure ASCII strings are now normalized in constant time by :func:`unicodedata.normalize
`.
(Contributed by
Dong-hee Na in :issue:`44987
`.)
*
:func:`sum` is now nearly 30% faster for integers smaller than ``2**30`
`.
(Contributed by
Stefan Behnel in :gh:`68264
`.)
*
:mod:`math` functions :func:`~math.comb` and :func:`~math.perm` are now up
to 10 times or more faster for large arguments (the speed up is larger for
larger *k*).
(Contributed by
Serhiy Storchaka in :issue:`3729
5`.)
*
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:`9116
5`.)
* Dict don't store hash value when all inserted keys are Unicode objects.
This reduces dict size. For example, ``sys.getsizeof(dict.fromkeys("abcdefg"))``
becomes 272 bytes from 352 bytes on 64bit platform.
* 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`.)
* :mod:`re`'s regular expression matching engine has been partially refactored,
and now uses computed gotos (or "threaded code") on supported platforms. As a
result, Python 3.11 executes the `pyperformance regular expression benchmarks
<https://pyperformance.readthedocs.io/benchmarks.html#regex-dna>`_ up to 10%
faster than Python 3.10.
* 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`.)
* 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`.)
.. _whatsnew311-faster-cpython:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment