You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extend zipfile's compression level support to LZMA #76909
In [1] (bpo-21417), support for setting an archive (or its files) compression level was added to the zipfile module.
That currently works for the ZIP_DEFLATED and ZIP_BZIP2 compression methods, but not for ZIP_LZMA. This is because zipfile includes its own implementation of LZMACompressor that hard-codes the default preset's parameters (see also [2]).
It should be possible to extend compression level settings to ZIP_LZMA by making zipfile.LZMACompressor more flexible, i.e. able to accept an LZMA preset. I think this would involve porting the function that translates presets to options (lzma_lzma_preset, see [3]) and passing in those options to lzma.LZMACompressor .
Activity
bbayles commentedon Jan 30, 2018
In [1] (bpo-21417), support for setting an archive (or its files) compression level was added to the zipfile module.
That currently works for the ZIP_DEFLATED and ZIP_BZIP2 compression methods, but not for ZIP_LZMA. This is because zipfile includes its own implementation of LZMACompressor that hard-codes the default preset's parameters (see also [2]).
It should be possible to extend compression level settings to ZIP_LZMA by making zipfile.LZMACompressor more flexible, i.e. able to accept an LZMA preset. I think this would involve porting the function that translates presets to options (lzma_lzma_preset, see [3]) and passing in those options to lzma.LZMACompressor .
[1] https://bugs.python.org/issue21417
[2] #5385
[3] https://git.tukaani.org/?p=xz.git;a=blob;f=src/liblzma/lzma/lzma_encoder_presets.c;hb=HEAD
Merge branch 'main' into pythongh-76909
serhiy-storchaka commentedon Jan 15, 2024
Why not use
compresslevelinstead ofpreset?bbayles commentedon Jan 15, 2024
Someone is welcome to adapt the PR to their taste.