Compression module APIs

Florian Weimer fw at deneb.enyo.de
Thu May 6 07:41:56 EDT 2010


* Chris Rebert:

> On Thu, May 6, 2010 at 4:09 AM, Florian Weimer <fw at deneb.enyo.de> wrote:
>> As far as I can see, the compression-related APIs (gzip, zlib, bzip2)
>> in Python 2.5 have three distinct APIs.  Is there really no unified
>> interface, or am I missing something?
>
> bz2.BZ2File and gzip.GzipFile both offer a file-like interface for
> reading/writing compressed files in their respective formats.
> The gzip module is already built on top of the zlib module, so there's
> no ZlibFile.
> zlib and bz2 also both offer compatible one-shot compress() and
> decompress() functions.
> So, the interfaces are sorta "unified", although it is true they're
> not grouped into a single generic "compression" module.

Some overlap is there.  But but there does not appear to be a way to
decompress a gzip stream on the fly (which is surprising, as this is a
fairly common operation), and there are no counterparts to
bz2.BZ2{Dec,C}ompressor.



More information about the Python-list mailing list