PyDocs

Nav

Data Compression and Archiving

GzipFile

gzip

class (source) Deprecated 3.9
  • GzipFile(filename=None, mode=None, compresslevel=6, fileobj=None, mtime=None)
Deprecated since 3.9. Opening GzipFile for writing without specifying the mode argument is deprecated.
The GzipFile class simulates most of the methods of a file object with
the exception of the truncate() method.

This class only supports opening files in binary mode.  If you need to
open a compressed file in text mode, use the gzip.open() function.
Changed in 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.12, 3.15
  • 3.1: Support for the with statement was added, along with the mtime constructor argument and mtime attribute.
  • 3.2: Support for zero-padded and unseekable files was added.
  • 3.3: The io.BufferedIOBase.read1() method is now implemented.
  • 3.4: Added support for the 'x' and 'xb' modes.
  • 3.5: Added support for writing arbitrary bytes-like objects. The read() method now accepts an argument of None.
  • 3.6: Accepts a path-like object.
  • 3.12: Remove the filename attribute, use the name attribute instead.
  • 3.15: The default compression level was reduced to 6 (down from 9). It is the default level used by most compression tools and a better tradeoff between speed and performance.
Members of GzipFile

m

mode
'rb' for reading and 'wb' for writing.
mtime
Last modification time read from stream, or None

n

name
The path to the gzip file on disk, as a str or bytes.

p

peek
Read n uncompressed bytes without advancing the file position.
0 Examples
No examples for gzip/GzipFile.
See Also
No see-alsos for gzip/GzipFile
0 Notes
No notes for GzipFile