diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-17 21:10:05 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-17 21:10:05 (GMT) |
commit | 79c5ef11d56e761445e334a7121764808e9e70cf (patch) | |
tree | 529b00a3e891a4c14b4c5e1ac6971f490ba62784 /Doc | |
parent | 852823d731a6370c078016f3825044eec74fbb4f (diff) | |
download | cpython-79c5ef11d56e761445e334a7121764808e9e70cf.zip cpython-79c5ef11d56e761445e334a7121764808e9e70cf.tar.gz cpython-79c5ef11d56e761445e334a7121764808e9e70cf.tar.bz2 |
Issue #3488: Provide convenient shorthand functions `gzip.compress`
and `gzip.decompress`. Original patch by Anand B. Pillai.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/gzip.rst | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index b99ac74..0401cd8 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -82,6 +82,17 @@ The module defines the following items: The *filename* argument is required; *mode* defaults to ``'rb'`` and *compresslevel* defaults to ``9``. +.. function:: compress(data, compresslevel=9) + + Compress the *data*, returning a :class:`bytes` object containing + the compressed data. *compresslevel* has the same meaning as in + the :class:`GzipFile` constructor above. + +.. function:: decompress(data) + + Decompress the *data*, returning a :class:`bytes` object containing the + uncompressed data. + .. _gzip-usage-examples: @@ -112,6 +123,11 @@ Example of how to GZIP compress an existing file:: f_out.close() f_in.close() +Example of how to GZIP compress a binary string:: + + import gzip + s_in = b"Lots of content here" + s_out = gzip.compress(s_in) .. seealso:: |