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.compress should have a wbits argument
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, rhpvorderman
Priority: normal Keywords: patch

Created on 2021-03-24 06:04 by rhpvorderman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25011 closed rhpvorderman, 2021-03-24 08:43
PR 27941 merged rhpvorderman, 2021-08-25 09:34
Messages (4)
msg389437 - (view) Author: Ruben Vorderman (rhpvorderman) * Date: 2021-03-24 06:04
zlib.compress can now only be used to output zlib blocks.
Arguably `zlib.compress(my_data, level, wbits=-15)` is even more useful as it gives you a raw deflate block. That is quite interesting if you are writing your own file format and want to use compression, but like to use a different hash.

Also gzip.compress(data, level, mtime) is extremely slow due to it instantiating a GzipFile object which then streams a bytes object. Explicitly not taking advantage of the fact that the bytes object is entirely in memory already (I will create another bug for this). zlib.compress(my_data, level, wbits=31) should be faster in all possible circumstances, but that option is not available now.
msg391881 - (view) Author: Ruben Vorderman (rhpvorderman) * Date: 2021-04-26 07:03
A patch was created, but has not been reviewed yet.
msg400922 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-09-02 15:03
Thanks for your contribution, Ruben! ✨ 🍰 ✨
msg400982 - (view) Author: Ruben Vorderman (rhpvorderman) * Date: 2021-09-03 07:28
Thanks for the review, Lukasz! It was fun to create the PR and optimize the performance for gzip.py as well.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87778
2021-09-03 07:28:10rhpvordermansetmessages: + msg400982
2021-09-02 15:03:59lukasz.langasetversions: - Python 3.10
2021-09-02 15:03:42lukasz.langasetstatus: open -> closed

nosy: + lukasz.langa
messages: + msg400922

resolution: fixed
stage: patch review -> resolved
2021-08-25 09:34:17rhpvordermansetpull_requests: + pull_request26387
2021-04-26 07:04:07rhpvordermansetversions: + Python 3.11
2021-04-26 07:03:33rhpvordermansetmessages: + msg391881
2021-03-25 08:24:55rhpvordermansetcomponents: + Extension Modules, - Library (Lib)
2021-03-24 08:44:19rhpvordermansettype: enhancement
2021-03-24 08:43:53rhpvordermansetkeywords: + patch
stage: patch review
pull_requests: + pull_request23768
2021-03-24 06:04:20rhpvordermancreate