diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -71,9 +71,23 @@ *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. + .. The following discussion of wbits is repeated under decompress(). + + *wbits* can take several ranges of values: + + * +8 to +15: The base two logarithm of the size of the + history buffer (the "window size") used when compressing data. + The window size can therefore range between 256 and 32768. + Larger values resulting in 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 trailer. + + * +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 trailer 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, @@ -124,15 +138,28 @@ 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 + .. The following discussion of wbits is repeated for compressobj. + + *wbits* can take several ranges of values: + + * +8 to +15: The base two logarithm of the size of the + history buffer (the "window size") used when compressing data. + The window size can therefore range between 256 and 32768. + Larger values resulting in 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 trailer. + + * +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 trailer in the output. + + 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. + 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 @@ -285,4 +312,3 @@ http://www.zlib.net/manual.html The zlib manual explains the semantics and usage of the library's many functions. -