Skip to content

Commit e2d0562

Browse files
committed
gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile
It is the default level used by most compression tools and a better tradeoff between speed and performance.
1 parent 0a54bd6 commit e2d0562

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Doc/library/gzip.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Note that additional file formats which can be decompressed by the
2626
The module defines the following items:
2727

2828

29-
.. function:: open(filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None)
29+
.. function:: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None)
3030

3131
Open a gzip-compressed file in binary or text mode, returning a :term:`file
3232
object`.
@@ -67,7 +67,7 @@ The module defines the following items:
6767

6868
.. versionadded:: 3.8
6969

70-
.. class:: GzipFile(filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None)
70+
.. class:: GzipFile(filename=None, mode=None, compresslevel=6, fileobj=None, mtime=None)
7171

7272
Constructor for the :class:`GzipFile` class, which simulates most of the
7373
methods of a :term:`file object`, with the exception of the :meth:`~io.IOBase.truncate`
@@ -184,7 +184,7 @@ The module defines the following items:
184184
attribute instead.
185185

186186

187-
.. function:: compress(data, compresslevel=9, *, mtime=0)
187+
.. function:: compress(data, compresslevel=6, *, mtime=0)
188188

189189
Compress the *data*, returning a :class:`bytes` object containing
190190
the compressed data. *compresslevel* and *mtime* have the same meaning as in

Lib/tarfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ def taropen(cls, name, mode="r", fileobj=None, **kwargs):
19111911
return cls(name, mode, fileobj, **kwargs)
19121912

19131913
@classmethod
1914-
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1914+
def gzopen(cls, name, mode="r", fileobj=None, compresslevel=6, **kwargs):
19151915
"""Open gzip compressed tar archive name for reading or writing.
19161916
Appending is not allowed.
19171917
"""
@@ -1944,7 +1944,7 @@ def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
19441944
return t
19451945

19461946
@classmethod
1947-
def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1947+
def bz2open(cls, name, mode="r", fileobj=None, compresslevel=6, **kwargs):
19481948
"""Open bzip2 compressed tar archive name for reading or writing.
19491949
Appending is not allowed.
19501950
"""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Adjust default compression level to 6 (down from 9) in gzip and tarfile.
2+
It is the default level used by most compression tools and a better
3+
tradeoff between speed and performance.

0 commit comments

Comments
 (0)