Skip to content

Instantly share code, notes, and snippets.

View hearues-zueke-github's full-sized avatar
🎯
Focusing

Hearues Zueke hearues-zueke-github

🎯
Focusing
View GitHub Profile
@john-science
john-science / gzip_files_in_python.md
Last active May 27, 2021 16:47
Reading & Writing GZIP Files Faster in Python

Reading & Writing GZIP Files in Python

I have been testing various ways to read and write text files with GZIP in Python. There were a lot of uninteresting results, but there were two I thought were worth sharing.

Writing GZIP files

If you have a big list of strings to write to a file, you might be tempted to do:

f = gzip.open(out_path, 'wb')

for line in lines: