Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zipfile: Allow specifying a compresslevel for zstd compression
  • Loading branch information
pR0Ps committed May 9, 2025
commit 4d59631f02784597e3da91351809f00bdf49c0e4
5 changes: 3 additions & 2 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,11 @@ def _get_compressor(compress_type, compresslevel=None):
if compresslevel is not None:
return bz2.BZ2Compressor(compresslevel)
return bz2.BZ2Compressor()
# compresslevel is ignored for ZIP_LZMA and ZIP_ZSTANDARD
# compresslevel is ignored for ZIP_LZMA
elif compress_type == ZIP_LZMA:
return LZMACompressor()
elif compress_type == ZIP_ZSTANDARD:
return zstd.ZstdCompressor()
return zstd.ZstdCompressor(level=compresslevel)
else:
return None

Expand Down Expand Up @@ -1362,6 +1362,7 @@ class ZipFile:
When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
When using ZIP_DEFLATED integers 0 through 9 are accepted.
When using ZIP_BZIP2 integers 1 through 9 are accepted.
When using ZIP_ZSTANDARD integers are accepted.
Comment thread
pR0Ps marked this conversation as resolved.
Outdated

"""

Expand Down