pythoncompression

Compression with best ratio in Python?


Which compression method in Python has the best compression ratio?

Is the commonly used zlib.compress() the best or are there some better options? I need to get the best compression ratio possible.

I am compresing strings and sending them over UDP. A typical string I compress has about 1,700,000 bytes.


Solution

  • I'm sure that there might be some more obscure formats with better compression, but lzma is the best, of those that are well supported. There are some python bindings here.

    EDIT

    Don't pick a format without testing, some algorithms do better depending on the data set.