diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -71,12 +71,25 @@ *method* is the compression algorithm. Currently, the only supported value is ``DEFLATED``. - *wbits* is the base two logarithm of the size of the window buffer. This - should be an integer from ``8`` to ``15``. Higher values give better - compression, but use more memory. + .. _wbits-description: + + *wbits* controls the size of the history buffer (or the "window size") + used when compressing data, and can take several ranges of values: + + * +8 to +15: The base two logarithm of the window size, which + therefore ranges between 256 and 32768. Larger values produce + better compression at the expense of greater memory usage. The + resulting output will include a zlib-specific header and trailer. + + * -8 to -15: Uses the absolute value of *wbits* as the window size, while + producing a raw output stream with no header or trailing checksum. + + * +24 to +31 = 16 + (8 to 15): Uses the low 4 bits of the value as + the window size, while including a basic :program:`gzip` header + and trailing checksum in the output. *memlevel* controls the amount of memory used for internal compression state. - Valid values range from ``1`` to ``9``. Higher values using more memory, + Valid values range from ``1`` to ``9``. Higher values use more memory, but are faster and produce smaller output. *strategy* is used to tune the compression algorithm. Possible values are @@ -118,21 +131,20 @@ .. function:: decompress(data[, wbits[, bufsize]]) - Decompresses the bytes in *data*, returning a bytes object containing the - uncompressed data. The *wbits* parameter controls the size of the window - buffer, and is discussed further below. - If *bufsize* is given, it is used as the initial size of the output - buffer. Raises the :exc:`error` exception if any error occurs. + Decompresses the bytes in *data*, returning a bytes object + containing the uncompressed data. The *wbits* parameter controls + the window size used for decompression. If *bufsize* is given, it + is used as the initial size of the output buffer. Raises the + :exc:`error` exception if any error occurs. - The absolute value of *wbits* is the base two logarithm of the size of the - history buffer (the "window size") used when compressing data. Its absolute - value should be between 8 and 15 for the most recent versions of the zlib - library, larger values resulting in better compression at the expense of greater - memory usage. When decompressing a stream, *wbits* must not be smaller - than the size originally used to compress the stream; using a too-small - value will result in an exception. The default value is therefore the - highest value, 15. When *wbits* is negative, the standard - :program:`gzip` header is suppressed. + *wbits* controls the size of the history buffer (or the "window + size") used for decompressing the data and + `is described further <#wbits-description>`__ in the documentation for + :func:`compressobj`. When decompressing a stream, *wbits* must not be + smaller than the + size originally used to compress the stream; using a too-small + value will result in an :exc:`error` exception. The default value + is therefore the highest value, 15. *bufsize* is the initial size of the buffer used to hold decompressed data. If more space is required, the buffer size will be increased as needed, so you @@ -145,7 +157,13 @@ Returns a decompression object, to be used for decompressing data streams that won't fit into memory at once. - The *wbits* parameter controls the size of the window buffer. + *wbits* controls the size of the history buffer (or the "window size") + used when compressing data, and `is described further <#wbits-description>`__ + in the documentation for :func:`compressobj`. When decompressing a stream, + *wbits* must not be smaller than the size originally used to + compress the stream; using a too-small value will result in an + :exc:`error` exception. The default value is therefore the highest + value, 15. The *zdict* parameter specifies a predefined compression dictionary. If provided, this must be the same dictionary as was used by the compressor that @@ -285,4 +303,3 @@ http://www.zlib.net/manual.html The zlib manual explains the semantics and usage of the library's many functions. -