bpo-41486: Faster bz2/lzma/zlib via new output buffering (GH-21740)

Faster bz2/lzma/zlib via new output buffering.
Also adds .readall() function to _compression.DecompressReader class
to take best advantage of this in the consume-all-output at once scenario.

Often a 5-20% speedup in common scenarios due to less data copying.

Contributed by Ma Lin.
This commit is contained in:
Ma Lin 2021-04-28 14:58:54 +08:00 committed by GitHub
parent a5e64444e6
commit f9bedb630e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 670 additions and 254 deletions

View file

@ -1243,6 +1243,12 @@ Optimizations
for more details. (Contributed by Victor Stinner and Pablo Galindo in
:issue:`38980`.)
* Use a new output buffer management code for :mod:`bz2` / :mod:`lzma` /
:mod:`zlib` modules, and add ``.readall()`` function to
``_compression.DecompressReader`` class. bz2 decompression 1.09x ~ 1.17x
faster, lzma decompression 1.20x ~ 1.32x faster, ``GzipFile.read(-1)`` 1.11x
~ 1.18x faster. (Contributed by Ma Lin, reviewed by Gregory P. Smith, in :issue:`41486`)
* Function parameters and their annotations are no longer computed at runtime,
but rather at compilation time. They are stored as a tuple of strings at the
bytecode level. It is now around 2 times faster to create a function with