![]() |
compression module for lz4? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: compression module for lz4? (/thread-35381.html) |
compression module for lz4? - Skaperen - Oct-27-2021 i would like to know if there is a module for decompressing the lz4 compression found in the Debian/Ubuntu "lz4" command (as opposed to the lzma compression found in the Debian/Ubuntu "lzma" and "xz" commands which is implement in the lzma module). anyone know (without guessing)? RE: compression module for lz4? - DeaD_EyE - Oct-27-2021 LZ4 is not xz .xz is using lzma compression. To get lz4 with Python: pip install lz4The module lzma is in the standard library. Example: # stdlib import subprocess import lzma # extern from lz4.frame import open as lz4_open # apt-get install python-lz4 or pip install lz4 # LZMA !!!! print("Compressing with lzma") with open("test.xz", "wb") as fd: subprocess.run(["xz"], input=b"Hello World", stdout=fd) print("Reading with lzma from stdlib") with lzma.open("test.xz", "rb") as fd: print(fd.read()) print() # LZ4 !!! print("Compressing with lz4") with open("test.lz4", "wb") as fd: subprocess.run(["lz4"], input=b"Hello World", stdout=fd) print("Reading lz4 with external lib") with lz4_open("test.lz4", "rb") as fd: print(fd.read(1024)) # without size I get a memory error |