A Python LZMA & XZ library with greater control over compression parameters.
In addition to CPython's stdlib lzma, lzma-cf can
- Compress and decompress XZ files in multithreaded mode
>>> import lzma_cf
>>> uncompressed = b'qwertyuiopasdfghjklzxcvbnm1234567890' * 10_000_000
>>> compressed_singlethreaded = lzma_cf.compress(uncompressed)
>>> compressed_multithreaded = lzma_cf.compress(uncompressed, threads=0)
>>> compressed_singlethreaded == compressed_multithreaded
False
>>> uncompressed == lzma_cf.decompress(compressed_singlethreaded)
True
>>> uncompressed == lzma_cf.decompress(compressed_multithreaded)
True$ python -mtimeit -s "import lzma_cf" -s "s=b'qwertyuiopasdfghjklzxcvbnm1234567890' * 10_000_000" "lzma_cf.compress(s)"
1 loop, best of 5: 3.74 sec per loop
$ python -mtimeit -s "import lzma_cf" -s "s=b'qwertyuiopasdfghjklzxcvbnm1234567890' * 10_000_000" "lzma_cf.compress(s, threads=0)"
1 loop, best of 5: 685 msec per looppip install lzma-cf
or
uv pip install lzma-cf
BSD-3-Clause AND MIT AND PSF-2.0
lzma-cf is derived from code that has passed through multiple projects by multiple authors
- CPython 3.3.0 added
lzmato the stdlib in_lzmamodule.c&lzma.py - backports.lzma repackaged CPython C-API code & adapted it
- lzmaffi forked backports.lzma & changed C-API bindings to CFFI bindings
- PyPy incorporated lzmaffi code into their stdlib & updated it
- lzma-cf (this project) uses PyPy code and builds on it