bpo-43613: Faster implementation of gzip.compress and gzip.decompress (GH-27941)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Ruben Vorderman 2021-09-02 17:02:59 +02:00 committed by GitHub
parent a7ef15aae8
commit ea23e7820f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 195 additions and 89 deletions

View file

@ -174,19 +174,30 @@ The module defines the following items:
Compress the *data*, returning a :class:`bytes` object containing
the compressed data. *compresslevel* and *mtime* have the same meaning as in
the :class:`GzipFile` constructor above.
the :class:`GzipFile` constructor above. When *mtime* is set to ``0``, this
function is equivalent to :func:`zlib.compress` with *wbits* set to ``31``.
The zlib function is faster.
.. versionadded:: 3.2
.. versionchanged:: 3.8
Added the *mtime* parameter for reproducible output.
.. versionchanged:: 3.11
Speed is improved by compressing all data at once instead of in a
streamed fashion. Calls with *mtime* set to ``0`` are delegated to
:func:`zlib.compress` for better speed.
.. function:: decompress(data)
Decompress the *data*, returning a :class:`bytes` object containing the
uncompressed data.
uncompressed data. This function is capable of decompressing multi-member
gzip data (multiple gzip blocks concatenated together). When the data is
certain to contain only one member the :func:`zlib.decompress` function with
*wbits* set to 31 is faster.
.. versionadded:: 3.2
.. versionchanged:: 3.11
Speed is improved by decompressing members at once in memory instead of in
a streamed fashion.
.. _gzip-usage-examples: