There is also Blosc:
https://github.com/Blosc/c-blosc
https://github.com/Blosc/python-blosc
that includes support for recent LZ4 r113 and different compression levels:
In []: import numpy as np
In []: w = np.fromfile('call_being_recorded.wav', dtype='i2')
In []: import lz4
In []: wlz4 = lz4.compress(w)
In []: import blosc
In []: wblosc1 = blosc.pack_array(w, clevel=1, cname='lz4')
In []: wblosc5 = blosc.pack_array(w, clevel=5, cname='lz4')
In []: wblosc9 = blosc.pack_array(w, clevel=9, cname='lz4')
In []: len(w.tostring()), len(wlz4), len(wblosc1), len(wblosc5),
len(wblosc9)
Out[]: (433598, 350521, 305565, 303147, 302138)
In this case, Blosc can compress more than stock LZ4 because it is meant
for binary data (like the 16-bit .wav file in this case).
And it is pretty fast too:
In []: %timeit lz4.compress(w)
1000 loops, best of 3: 1.01 ms per loop
In []: %timeit blosc.pack_array(w, clevel=5, cname='lz4')
1000 loops, best of 3: 1.64 ms per loop
although for maximum speed, the compress_ptr function is best:
In []: %timeit blosc.compress_ptr(w.__array_interface__['data'][0],
len(w), 2, clevel=5, cname='lz4')
1000 loops, best of 3: 880 µs per loop
Blosc also comes with native support for other compressors, like
'blosclz', 'lz4hc', 'snappy' and 'zlib', so you can choose which one
adapts better to your use case.
Francesc
On 3/15/14, 11:16 AM, Yann Collet wrote:
> Hi Basj
>
>
> Steeve Morin's python version is based on LZ4 r91.
> The capability to select compression level is relatively new, and only
> available since r113.
> So it would require Steeve to upgrade his port to get this capability.
>
>
> Regards
>
> Yann
>
> Le samedi 15 mars 2014 10:48:19 UTC+1, Basj a écrit :
>
> Hello,
>
> Do you know how to change the compression level with Python-LZ4
> (
https://github.com/steeve/python-lz4
> <
https://github.com/steeve/python-lz4>) ?
>
> When using :
>
> import lz4
> lz4.compress(data)
>
> it seems that it's not possible (yet) to change the compression level (I see that -1 to -9 level is possible here :
http://fastcompression.blogspot.fr/p/lz4.html <
http://fastcompression.blogspot.fr/p/lz4.html>)
> Any idea on how to do this ?
>
> Best regards,
> basj
>
> --
> Vous recevez ce message, car vous êtes abonné au groupe Google Groupes
> "LZ4c".
> Pour vous désabonner de ce groupe et ne plus en recevoir les messages,
> envoyez un e-mail à l'adresse
lz4c+uns...@googlegroups.com
> <mailto:
lz4c+uns...@googlegroups.com>.
> Pour obtenir davantage d'options, consultez la page
>
https://groups.google.com/d/optout.
--
Francesc Alted