From b6d2609989b8cf1f2a22e9cdb8c7816a99b7f6dd Mon Sep 17 00:00:00 2001 From: Jaden-Varkey Date: Mon, 29 Jun 2026 23:27:07 +0530 Subject: [PATCH] Fix outdated default compresslevel in gzip docs The default compression level for gzip.open(), the GzipFile constructor and gzip.compress() was lowered from 9 to 6 (it now uses _COMPRESS_LEVEL_TRADEOFF), and the signatures and versionchanged notes were updated accordingly. A couple of docstrings and one paragraph in the library docs still said the default was 9, which was misleading. Update them to match the actual default of 6. --- Doc/library/gzip.rst | 2 +- Lib/gzip.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index 9211e5f18c6b6e..7ed4fc39e6aada 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -112,7 +112,7 @@ The module defines the following items: The *compresslevel* argument is an integer from ``0`` to ``9`` controlling the level of compression; ``1`` is fastest and produces the least compression, and ``9`` is slowest and produces the most compression. ``0`` - is no compression. The default is ``9``. + is no compression. The default is ``6``. The optional *mtime* argument is the timestamp requested by gzip. The time is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. Set diff --git a/Lib/gzip.py b/Lib/gzip.py index 247efc01527bb1..5b6ebcfef45c3a 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -39,7 +39,7 @@ def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_TRADEOFF, The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for binary mode, or "rt", "wt", "xt" or "at" for text mode. The default - mode is "rb", and the default compresslevel is 9. + mode is "rb", and the default compresslevel is 6. For binary mode, this function is equivalent to the GzipFile constructor: GzipFile(filename, mode, compresslevel). In this case, @@ -186,7 +186,7 @@ def __init__(self, filename=None, mode=None, The compresslevel argument is an integer from 0 to 9 controlling the level of compression; 1 is fastest and produces the least compression, and 9 is slowest and produces the most compression. - 0 is no compression at all. The default is 9. + 0 is no compression at all. The default is 6. The optional mtime argument is the timestamp requested by gzip. The time is in Unix format, i.e., seconds since 00:00:00 UTC,