Created
August 26, 2021 20:25
-
-
Save en0/d4702bcec798a7e953d0bd2b808ec5f5 to your computer and use it in GitHub Desktop.
gzip with zlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib | |
compressor = zlib.compressobj(method=zlib.DEFLATED, wbits=zlib.MAX_WBITS | 16) | |
with open('output.txt', 'wb') as fd: | |
for i in range(10000): | |
fd.write(compressor.compress(f"Line number {i}\n".encode('utf-8'))) | |
fd.write(compressor.flush()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment