Skip to content

Commit a490d67

Browse files
emmatypingStanFromIrelandvstinner
authored
[3.14] zlib.rst: Link to constants and deduplicate text (GH-140115) (GH-140349)
* Link to compression setting constants from compression functions * De-duplicate descriptions of the constants (cherry picked from commit 091e851) Co-authored-by: Stan Ulbrych <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent c7fda9b commit a490d67

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

Doc/library/zlib.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,20 @@ The available exception and functions in this module are:
4444
.. versionchanged:: 3.0
4545
The result is always unsigned.
4646

47-
.. function:: compress(data, /, level=-1, wbits=MAX_WBITS)
47+
.. function:: compress(data, /, level=Z_DEFAULT_COMPRESSION, wbits=MAX_WBITS)
4848

4949
Compresses the bytes in *data*, returning a bytes object containing compressed data.
5050
*level* is an integer from ``0`` to ``9`` or ``-1`` controlling the level of compression;
51-
``1`` (Z_BEST_SPEED) is fastest and produces the least compression, ``9`` (Z_BEST_COMPRESSION)
52-
is slowest and produces the most. ``0`` (Z_NO_COMPRESSION) is no compression.
53-
The default value is ``-1`` (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default
54-
compromise between speed and compression (currently equivalent to level 6).
51+
See :const:`Z_BEST_SPEED` (``1``), :const:`Z_BEST_COMPRESSION` (``9``),
52+
:const:`Z_NO_COMPRESSION` (``0``), and the default,
53+
:const:`Z_DEFAULT_COMPRESSION` (``-1``) for more information about these values.
5554

5655
.. _compress-wbits:
5756

5857
The *wbits* argument controls the size of the history buffer (or the
5958
"window size") used when compressing data, and whether a header and
6059
trailer is included in the output. It can take several ranges of values,
61-
defaulting to ``15`` (MAX_WBITS):
60+
defaulting to ``15`` (:const:`MAX_WBITS`):
6261

6362
* +9 to +15: The base-two logarithm of the window size, which
6463
therefore ranges between 512 and 32768. Larger values produce
@@ -82,17 +81,15 @@ The available exception and functions in this module are:
8281
The *wbits* parameter is now available to set window bits and
8382
compression type.
8483

85-
.. function:: compressobj(level=-1, method=DEFLATED, wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=Z_DEFAULT_STRATEGY[, zdict])
84+
.. function:: compressobj(level=Z_DEFAULT_COMPRESSION, method=DEFLATED, wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=Z_DEFAULT_STRATEGY[, zdict])
8685

8786
Returns a compression object, to be used for compressing data streams that won't
8887
fit into memory at once.
8988

9089
*level* is the compression level -- an integer from ``0`` to ``9`` or ``-1``.
91-
A value of ``1`` (Z_BEST_SPEED) is fastest and produces the least compression,
92-
while a value of ``9`` (Z_BEST_COMPRESSION) is slowest and produces the most.
93-
``0`` (Z_NO_COMPRESSION) is no compression. The default value is ``-1`` (Z_DEFAULT_COMPRESSION).
94-
Z_DEFAULT_COMPRESSION represents a default compromise between speed and compression
95-
(currently equivalent to level 6).
90+
See :const:`Z_BEST_SPEED` (``1``), :const:`Z_BEST_COMPRESSION` (``9``),
91+
:const:`Z_NO_COMPRESSION` (``0``), and the default,
92+
:const:`Z_DEFAULT_COMPRESSION` (``-1``) for more information about these values.
9693

9794
*method* is the compression algorithm. Currently, the only supported value is
9895
:const:`DEFLATED`.
@@ -107,7 +104,7 @@ The available exception and functions in this module are:
107104

108105
*strategy* is used to tune the compression algorithm. Possible values are
109106
:const:`Z_DEFAULT_STRATEGY`, :const:`Z_FILTERED`, :const:`Z_HUFFMAN_ONLY`,
110-
:const:`Z_RLE` (zlib 1.2.0.1) and :const:`Z_FIXED` (zlib 1.2.2.2).
107+
:const:`Z_RLE` and :const:`Z_FIXED`.
111108

112109
*zdict* is a predefined compression dictionary. This is a sequence of bytes
113110
(such as a :class:`bytes` object) containing subsequences that are expected
@@ -221,7 +218,7 @@ Compression objects support the following methods:
221218
All pending input is processed, and a bytes object containing the remaining compressed
222219
output is returned. *mode* can be selected from the constants
223220
:const:`Z_NO_FLUSH`, :const:`Z_PARTIAL_FLUSH`, :const:`Z_SYNC_FLUSH`,
224-
:const:`Z_FULL_FLUSH`, :const:`Z_BLOCK` (zlib 1.2.3.4), or :const:`Z_FINISH`,
221+
:const:`Z_FULL_FLUSH`, :const:`Z_BLOCK`, or :const:`Z_FINISH`,
225222
defaulting to :const:`Z_FINISH`. Except :const:`Z_FINISH`, all constants
226223
allow compressing further bytestrings of data, while :const:`Z_FINISH` finishes the
227224
compressed stream and prevents compressing any more data. After calling :meth:`flush`
@@ -339,24 +336,25 @@ behavior:
339336

340337
.. data:: Z_NO_COMPRESSION
341338

342-
Compression level ``0``.
339+
Compression level ``0``; no compression.
343340

344341
.. versionadded:: 3.6
345342

346343

347344
.. data:: Z_BEST_SPEED
348345

349-
Compression level ``1``.
346+
Compression level ``1``; fastest and produces the least compression.
350347

351348

352349
.. data:: Z_BEST_COMPRESSION
353350

354-
Compression level ``9``.
351+
Compression level ``9``; slowest and produces the most compression.
355352

356353

357354
.. data:: Z_DEFAULT_COMPRESSION
358355

359-
Default compression level (``-1``).
356+
Default compression level (``-1``); a compromise between speed and
357+
compression. Currently equivalent to compression level ``6``.
360358

361359

362360
.. data:: Z_DEFAULT_STRATEGY

0 commit comments

Comments
 (0)