Книга: Learning Concurrency in Python
Назад: Reading/writing SQLite3
Дальше: Parallel execution

Compressed files

PyFunctional handles compressed files that have been compressed with gzip, lzma/xz, and bz2 with ease. It automatically handles the detection of whether or not a file is compressed, so you can essentially work with compressed files as if they were no different from normal files.

This may impact the speed at which you are able to manipulate these files though, as there is the overhead of working with compressed data. However, in my experience this hasn't been an extreme overhead.

When it comes to writing back to these files, you simply have to set the compression parameter to the following functions:

  • gzip or gz for gzip compression
  • lzma or xz for lzma compression
  • bz2 for bz2 compression

This parameter exists on every to_ function that exists within PyFunctional, and the combination of this and the automatic detection makes working with compressed files an absolute delight.

Назад: Reading/writing SQLite3
Дальше: Parallel execution