From ea23e7820f02840368569db8082bd0ca4d59b62a Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Thu, 2 Sep 2021 17:02:59 +0200 Subject: bpo-43613: Faster implementation of gzip.compress and gzip.decompress (GH-27941) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ɓukasz Langa --- Modules/zlibmodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Modules/zlibmodule.c') diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 3efb24a679..27a6d9a936 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -310,13 +310,15 @@ zlib.compress / level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION Compression level, in 0-9 or -1. + wbits: int(c_default="MAX_WBITS") = MAX_WBITS + The window buffer size and container format. Returns a bytes object containing compressed data. [clinic start generated code]*/ static PyObject * -zlib_compress_impl(PyObject *module, Py_buffer *data, int level) -/*[clinic end generated code: output=d80906d73f6294c8 input=638d54b6315dbed3]*/ +zlib_compress_impl(PyObject *module, Py_buffer *data, int level, int wbits) +/*[clinic end generated code: output=46bd152fadd66df2 input=c4d06ee5782a7e3f]*/ { PyObject *RetVal; int flush; @@ -336,7 +338,8 @@ zlib_compress_impl(PyObject *module, Py_buffer *data, int level) zst.zalloc = PyZlib_Malloc; zst.zfree = PyZlib_Free; zst.next_in = ibuf; - int err = deflateInit(&zst, level); + int err = deflateInit2(&zst, level, DEFLATED, wbits, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY); switch (err) { case Z_OK: -- cgit v1.2.1