Issue #15677: Document that zlib and gzip accept a compression level of 0 to mean 'no compression'.

Patch by Brian Brazil.
This commit is contained in:
Nadeem Vawda 2012-11-11 13:52:10 +01:00
parent c3197254ac
commit 04050b80b1
5 changed files with 17 additions and 10 deletions

View file

@ -49,9 +49,10 @@ The module defines the following items:
not given, the 'b' flag will be added to the mode to ensure the file is opened not given, the 'b' flag will be added to the mode to ensure the file is opened
in binary mode for cross-platform portability. in binary mode for cross-platform portability.
The *compresslevel* argument is an integer from ``1`` to ``9`` controlling the The *compresslevel* argument is an integer from ``0`` to ``9`` controlling
level of compression; ``1`` is fastest and produces the least compression, and the level of compression; ``1`` is fastest and produces the least
``9`` is slowest and produces the most compression. The default is ``9``. compression, and ``9`` is slowest and produces the most compression. ``0``
is no compression. The default is ``9``.
The *mtime* argument is an optional numeric timestamp to be written to The *mtime* argument is an optional numeric timestamp to be written to
the stream when compressing. All :program:`gzip` compressed streams are the stream when compressing. All :program:`gzip` compressed streams are

View file

@ -62,18 +62,19 @@ The available exception and functions in this module are:
.. function:: compress(string[, level]) .. function:: compress(string[, level])
Compresses the data in *string*, returning a string contained compressed data. Compresses the data in *string*, returning a string contained compressed data.
*level* is an integer from ``1`` to ``9`` controlling the level of compression; *level* is an integer from ``0`` to ``9`` controlling the level of compression;
``1`` is fastest and produces the least compression, ``9`` is slowest and ``1`` is fastest and produces the least compression, ``9`` is slowest and
produces the most. The default value is ``6``. Raises the :exc:`error` produces the most. ``0`` is no compression. The default value is ``6``.
exception if any error occurs. Raises the :exc:`error` exception if any error occurs.
.. function:: compressobj([level]) .. function:: compressobj([level])
Returns a compression object, to be used for compressing data streams that won't Returns a compression object, to be used for compressing data streams that won't
fit into memory at once. *level* is an integer from ``1`` to ``9`` controlling fit into memory at once. *level* is an integer from ``0`` to ``9`` controlling
the level of compression; ``1`` is fastest and produces the least compression, the level of compression; ``1`` is fastest and produces the least compression,
``9`` is slowest and produces the most. The default value is ``6``. ``9`` is slowest and produces the most. ``0`` is no compression. The default
value is ``6``.
.. function:: crc32(data[, value]) .. function:: crc32(data[, value])

View file

@ -66,9 +66,10 @@ class GzipFile(io.BufferedIOBase):
Be aware that only the 'rb', 'ab', and 'wb' values should be used Be aware that only the 'rb', 'ab', and 'wb' values should be used
for cross-platform portability. for cross-platform portability.
The compresslevel argument is an integer from 1 to 9 controlling the The compresslevel argument is an integer from 0 to 9 controlling the
level of compression; 1 is fastest and produces the least compression, level of compression; 1 is fastest and produces the least compression,
and 9 is slowest and produces the most compression. The default is 9. and 9 is slowest and produces the most compression. 0 is no compression
at all. The default is 9.
The mtime argument is an optional numeric timestamp to be written The mtime argument is an optional numeric timestamp to be written
to the stream when compressing. All gzip compressed streams to the stream when compressing. All gzip compressed streams

View file

@ -120,6 +120,7 @@ Monty Brandenberg
Georg Brandl Georg Brandl
Christopher Brannon Christopher Brannon
Terrence Brannon Terrence Brannon
Brian Brazil
Dave Brennan Dave Brennan
Tom Bridgman Tom Bridgman
Keith Briggs Keith Briggs

View file

@ -556,6 +556,9 @@ Tools/Demos
Documentation Documentation
------------- -------------
- Issue #15677: Document that zlib and gzip accept a compression level of 0 to
mean 'no compression'. Patch by Brian Brazil.
- Issue #8040: added a version switcher to the documentation. Patch by - Issue #8040: added a version switcher to the documentation. Patch by
Yury Selivanov. Yury Selivanov.