Python lzma Module
Example
Compress and decompress bytes:
import lzma
data = b"Tobias"
xz = lzma.compress(data)
print(xz)
print(lzma.decompress(xz))
Try it Yourself »
Definition and Usage
The lzma module provides compression and decompression using the LZMA algorithm (commonly used in .xz files).
Use it to reduce storage or transfer size for binary data. It supports streaming and one-shot operations.
Members
Member | Description |
---|---|
compress() | Compress data and return the compressed bytes. |
decompress() | Decompress LZMA-compressed bytes. |
LZMAFile | File object for reading and writing .xz files. |
FILTER_LZMA2 | Filter constant for LZMA2 compression. |