summaryrefslogtreecommitdiff
path: root/Doc/library/gzip.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-17 21:10:05 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-17 21:10:05 +0000
commit79c5ef11d56e761445e334a7121764808e9e70cf (patch)
tree529b00a3e891a4c14b4c5e1ac6971f490ba62784 /Doc/library/gzip.rst
parent852823d731a6370c078016f3825044eec74fbb4f (diff)
downloadcpython-git-79c5ef11d56e761445e334a7121764808e9e70cf.tar.gz
Issue #3488: Provide convenient shorthand functions `gzip.compress`
and `gzip.decompress`. Original patch by Anand B. Pillai.
Diffstat (limited to 'Doc/library/gzip.rst')
-rw-r--r--Doc/library/gzip.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst
index b99ac740fd..0401cd8211 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::