mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
a7ef15aae8
commit
ea23e7820f
8 changed files with 195 additions and 89 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue