This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: zlib compressobj: expose missing knobs
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, oberstet
Priority: normal Keywords:

Created on 2013-10-17 08:06 by oberstet, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg200114 - (view) Author: Tobias Oberstein (oberstet) Date: 2013-10-17 08:06
The zlib library provides a couple of knobs to control the behavior and resource consumption of compression:

    ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
                                         int  level,
                                         int  method,
                                         int  windowBits,
                                         int  memLevel,
                                         int  strategy));

Of these, only `level`, `method` and `windowBits` are exposed on `zlib.compressobj` (and only the first is even documented: see issue #19277).

However, as was recently found from emperical evidence in the context of WebSocket compression

http://www.ietf.org/mail-archive/web/hybi/current/msg10222.html

the `memLevel` parameter in particular is very valuable in controlling memory consumption.

For WebSocket compression (with JSON payload), the following parameter set was found to provide a useful resource-consumption/compression-ratio tradeoff:

window bits=11
memory level=4

Hence, it would be useful to expose _all_ parameters in Python, that is `memLevel` and `strategy` too.
msg200148 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-17 17:41
Thanks for the suggestion; the parameters have already been added in Python 3.3, see http://docs.python.org/3/library/zlib.html#zlib.compressobj.
msg200149 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-17 17:46
Actually, compressobj() has always supported up to five arguments (named level, method, wbits, memlevel, strategy); I'll document this for 2.7 for issue 19277.

The new thing in 3.3 are support for keyword arguments and the zdict parameter.
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63477
2013-10-17 17:46:45georg.brandlsetmessages: + msg200149
2013-10-17 17:41:06georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg200148

resolution: out of date
2013-10-17 08:06:27oberstetcreate