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:
But, it turns out that it’s (10-20%) faster to do:
Reading GZIP files
If you have a big GZIP file to read (text, not binary), you might be temped to read it like:
But it turns out it can be up to 3 times faster to read it like: