I need to figure out how to write file output to a compressed file in Python, similar to the two-liner below:
open ZIPPED, \"| gzip -c > zipped.gz\";
print ZI
Using the gzip module is the official one-way-to-do-it and it's unlikely that any other pure python approach will go faster. This is especially true because the size of your data rules out in-memory options. Most likely, the fastest way is to write the full file to disk and use subprocess to call gz on that file.