Skip to content
Advertisement

Python zipfile, How to set the compression level?

Python supports zipping files when zlib is available, ZIP_DEFLATE

see: https://docs.python.org/3.4/library/zipfile.html

The zip command-line program on Linux supports -1 fastest, -9 best.

Is there a way to set the compression level of a zip file created in Python’s zipfile module?

Advertisement

Answer

Starting from python 3.7, the zipfile module added the compresslevel parameter.

https://docs.python.org/3/library/zipfile.html

I know this question is dated, but for people like me, that fall in this question, it may be a better option than the accepted one.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement