blob: c0ab11712b445999c6bac12ea6d6e4eef6c74d0c [file] [log] [blame]
Guido van Rossum04bc9d61997-04-30 18:12:27 +00001% zlib compression module version A.01.02
2% Alpha test release.
3% Written by A.M. Kuchling (amk@magnet.com)
4% Comments are welcomed.
5%
6% Can you think of a better name than zlib? (The module's purpose isn't
7% really obvious from the name)
8
9\section{Built-in Module \sectcode{zlib}}
10\bimodindex{zlib}
11
12For applications that require data compression, the functions in this
13module allow compression and decompression, using a library based on
14GNU zip. The library is available at
15\code{ftp://godzilli.cs.sunysb.edu/pub/ngf/zlib-1.00.tar.gz},
16and is mirrored at
17\code{ftp://ftp.uu.net/graphics/png/src/zlib-1.00.tar.gz}. Version
181.00 is the most recent version as of March 18, 1996; use a later
19version if one is available.
20
21The available functions in this module are:
22
23\renewcommand{\indexsubitem}{(in module zlib)}
24\begin{funcdesc}{adler32}{string\optional{\, value}}
25 Computes a Adler-32 checksum of \var{string}. (An Adler-32
26 checksum is almost as reliable as a CRC32 but can be computed much
27 more quickly.) If \var{value} is present, it is used as the
28 starting value of the checksum; otherwise, a fixed default value is
29 used. This allows computing a running checksum over the
30 concatenation of several input strings. The algorithm is not
31 cryptographically strong, and should not be used for
32 authentication or digital signatures.
33\end{funcdesc}
34
35\begin{funcdesc}{compress}{string\optional{\, level}}
36Compresses the data in \var{string}, returning a string contained
37compressed data. \var{level} is an integer from 1 to 9 controlling
38the level of compression; 1 is fastest and produces the least
39compression, 9 is slowest and produces the most. The default value is
406, which . Raises the \code{zlib.error} exception if any error occurs.
41\end{funcdesc}
42
43\begin{funcdesc}{compressobj}{\optional{level}}
44Returns a compression object, to be used for compressing data streams
45 that won't fit into memory at once. \var{level} is an integer from
46 1 to 9 controlling the level of compression; 1 is fastest and
47 produces the least compression, 9 is slowest and produces the most.
48 The default value is 6.
49\end{funcdesc}
50
51\begin{funcdesc}{crc32}{string\optional{\, value}}
52 Computes a CRC (Cyclic Redundancy Check) sum of \var{string}. If
53 \var{value} is present, it is used as the starting value of the
54 checksum; otherwise, a fixed default value is used. This allows
55 computing a running checksum over the concatenation of several
56 input strings. The algorithm is not cryptographically strong, and
57 should not be used for authentication or digital signatures.
58\end{funcdesc}
59
60\begin{funcdesc}{decompress}{string}
61Decompresses the data in \var{string}, returning a string containing
62the uncompressed data. Raises the \code{zlib.error} exception if any
63error occurs.
64\end{funcdesc}
65
66\begin{funcdesc}{decompressobj}{\optional{wbits}}
67Returns a compression object, to be used for decompressing data streams
68 that won't fit into memory at once. The \var{wbits} parameter controls the size of the window buffer; usually this can be left alone.
69\end{funcdesc}
70
71Compression objects support the following methods:
72
73\begin{funcdesc}{compress}{string}
74Compress \var{string}, returning a string containing compressed data
75for at least part of the data in \var{string}. This data should be
76concatenated to the output produced by any preceding calls to the
77\code{compress()} method. Some input may be kept in internal buffers
78for later processing.
79\end{funcdesc}
80
81\begin{funcdesc}{flush}{}
82All pending input is processed, and an string containing the remaining
83compressed output is returned. After calling \code{flush()}, the
84\code{compress()} method cannot be called again; the only realistic
85action is to delete the object.
86\end{funcdesc}
87
88Decompression objects support the following methods:
89
90\begin{funcdesc}{decompress}{string}
91Decompress \var{string}, returning a string containing the
92uncompressed data corresponding to at least part of the data in
93\var{string}. This data should be concatenated to the output produced
94by any preceding calls to the
95\code{decompress()} method. Some of the input data may be preserved in internal buffers
96for later processing.
97\end{funcdesc}
98
99\begin{funcdesc}{flush}{}
100All pending input is processed, and a string containing the remaining
101uncompressed output is returned. After calling \code{flush()}, the
102\code{decompress()} method cannot be called again; the only realistic
103action is to delete the object.
104\end{funcdesc}
105
106
107