annotate Doc/libzlib.tex @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents ef8a15902a48
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5387
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Built-in Module \sectcode{zlib}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \bimodindex{zlib}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 For applications that require data compression, the functions in this
5390
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
5 module allow compression and decompression, using the zlib library,
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
6 which is based on GNU zip. The zlib library has its own home page at
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
7 \code{http://www.cdrom.com/pub/infozip/zlib/}.
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
8 Version 1.0.4 is the most recent version as of April 30, 1997; use a
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
9 later version if one is available.
5387
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 The available functions in this module are:
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 \renewcommand{\indexsubitem}{(in module zlib)}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 \begin{funcdesc}{adler32}{string\optional{\, value}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 Computes a Adler-32 checksum of \var{string}. (An Adler-32
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 checksum is almost as reliable as a CRC32 but can be computed much
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 more quickly.) If \var{value} is present, it is used as the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 starting value of the checksum; otherwise, a fixed default value is
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 used. This allows computing a running checksum over the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 concatenation of several input strings. The algorithm is not
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 cryptographically strong, and should not be used for
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 authentication or digital signatures.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 \begin{funcdesc}{compress}{string\optional{\, level}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 Compresses the data in \var{string}, returning a string contained
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 compressed data. \var{level} is an integer from 1 to 9 controlling
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 the level of compression; 1 is fastest and produces the least
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 compression, 9 is slowest and produces the most. The default value is
5676
ef8a15902a48 Fix a sentence which ends "...is 6, which." (AMK)
Guido van Rossum <guido@python.org>
parents: 5390
diff changeset
30 6. Raises the \code{zlib.error} exception if any error occurs.
5387
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 \begin{funcdesc}{compressobj}{\optional{level}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 Returns a compression object, to be used for compressing data streams
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 that won't fit into memory at once. \var{level} is an integer from
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 1 to 9 controlling the level of compression; 1 is fastest and
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 produces the least compression, 9 is slowest and produces the most.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 The default value is 6.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 \begin{funcdesc}{crc32}{string\optional{\, value}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 Computes a CRC (Cyclic Redundancy Check) sum of \var{string}. If
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 \var{value} is present, it is used as the starting value of the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 checksum; otherwise, a fixed default value is used. This allows
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 computing a running checksum over the concatenation of several
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 input strings. The algorithm is not cryptographically strong, and
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 should not be used for authentication or digital signatures.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 \begin{funcdesc}{decompress}{string}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 Decompresses the data in \var{string}, returning a string containing
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 the uncompressed data. Raises the \code{zlib.error} exception if any
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 error occurs.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 \begin{funcdesc}{decompressobj}{\optional{wbits}}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 Returns a compression object, to be used for decompressing data streams
5390
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
58 that won't fit into memory at once. The \var{wbits} parameter
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
59 controls the size of the window buffer; usually this can be left
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
60 alone.
5387
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 Compression objects support the following methods:
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 \begin{funcdesc}{compress}{string}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 Compress \var{string}, returning a string containing compressed data
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 for at least part of the data in \var{string}. This data should be
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 concatenated to the output produced by any preceding calls to the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 \code{compress()} method. Some input may be kept in internal buffers
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 for later processing.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 \begin{funcdesc}{flush}{}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 All pending input is processed, and an string containing the remaining
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 compressed output is returned. After calling \code{flush()}, the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 \code{compress()} method cannot be called again; the only realistic
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 action is to delete the object.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 Decompression objects support the following methods:
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
81
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 \begin{funcdesc}{decompress}{string}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 Decompress \var{string}, returning a string containing the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 uncompressed data corresponding to at least part of the data in
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 \var{string}. This data should be concatenated to the output produced
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 by any preceding calls to the
5390
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
87 \code{decompress()} method. Some of the input data may be preserved
b24e84a0f30b Updated web ref and version#. Folded some long lines.
Guido van Rossum <guido@python.org>
parents: 5387
diff changeset
88 in internal buffers for later processing.
5387
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 \begin{funcdesc}{flush}{}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 All pending input is processed, and a string containing the remaining
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 uncompressed output is returned. After calling \code{flush()}, the
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 \code{decompress()} method cannot be called again; the only realistic
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 action is to delete the object.
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 \end{funcdesc}
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
98
09c58b174989 zlib by AMK
Guido van Rossum <guido@python.org>
parents:
diff changeset
99