[New-bugs-announce] [issue19278] zlib compressobj: expose missing knobs

Tobias Oberstein report at bugs.python.org
Thu Oct 17 10:06:27 CEST 2013

New submission from Tobias Oberstein:

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


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.

components: Library (Lib)
messages: 200114
nosy: oberstet
priority: normal
severity: normal
status: open
title: zlib compressobj: expose missing knobs
type: enhancement
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list