8000 gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 by gpshead · Pull Request #120480 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112346: Document the OS byte in gzip.compress output change in 3.11 #120480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Doc/library/gzip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ The module defines the following items:
.. 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.
:func:`zlib.compress` for better speed. In this situation the
output may contain a gzip header "OS" byte value other than 255
"unknown" as supplied by the underlying zlib implementation.

.. versionchanged:: 3.13
The gzip header OS byte is guaranteed to be set to 255 when this function
Expand Down
15 changes: 15 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,21 @@ functools
(Contributed by Yurii Karabas in :issue:`46014`.)


.. _whatsnew311-gzip:

gzip
----

* The :func:`gzip.compress` function is now faster when used with the
**mtime=0** argument as it delegates the compression entirely to a single
:func:`zlib.compress` operation. There is one side effect of this change: The
gzip file header contains an "OS" byte in its header. That was traditionally
always set to a value of 255 representing "unknown" by the :mod:`gzip`
module. Now, when using :func:`~gzip.compress` with **mtime=0**, it may be
set to a different value by the underlying zlib C library Python was linked
against.
(See :gh:`112346` for details on the side effect.)

.. _whatsnew311-hashlib:

hashlib
Expand Down
Loading
0