8000 [3.12] gh-112346: Document the OS byte in `gzip.compress` output chan… · python/cpython@40ce124 · GitHub
[go: up one dir, main page]

Skip to content

Commit 40ce124

Browse files
[3.12] gh-112346: Document the OS byte in gzip.compress output change in 3.11 (GH-120480) (#120613)
gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 (GH-120480) (cherry picked from commit bac4eda) gh-112346: Describe the "os" byte in gzip output change. Co-authored-by: Gregory P. Smith <greg@krypto.org>
1 parent 717d2bd commit 40ce124

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Doc/library/gzip.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ The module defines the following items:
194194
.. versionchanged:: 3.11
195195
Speed is improved by compressing all data at once instead of in a
196196
streamed fashion. Calls with *mtime* set to ``0`` are delegated to
197-
:func:`zlib.compress` for better speed.
197+
:func:`zlib.compress` for better speed. In this situation the
198+
output may contain a gzip header "OS" byte value other than 255
199+
"unknown" as supplied by the underlying zlib implementation.
198200

199201
.. function:: decompress(data)
200202

Doc/whatsnew/3.11.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,21 @@ functools
768768
(Contributed by Yurii Karabas in :issue:`46014`.)
769769

770770

771+
.. _whatsnew311-gzip:
772+
773+
gzip
774+
----
775+
776+
* The :func:`gzip.compress` function is now faster when used with the
777+
**mtime=0** argument as it delegates the compression entirely to a single
778+
:func:`zlib.compress` operation. There is one side effect of this change: The
779+
gzip file header contains an "OS" byte in its header. That was traditionally
780+
always set to a value of 255 representing "unknown" by the :mod:`gzip`
781+
module. Now, when using :func:`~gzip.compress` with **mtime=0**, it may be
782+
set to a different value by the underlying zlib C library Python was linked
783+
against.
784+
(See :gh:`112346` for details on the side effect.)
785+
771786
.. _whatsnew311-hashlib:
772787

773788
hashlib

0 commit comments

Comments
 (0)
0