Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compression module for lz4?
#1
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)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
LZ4 is not xz.

xz is using lzma compression.

To get lz4 with Python:
pip install lz4
The 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
    
    
Skaperen likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  That compression method is not supported tester_V 9 3,464 Jan-31-2023, 07:05 PM
Last Post: tester_V
  CPC File Format (Cartesian Perceptual Compression) - Can Python Convert / Handle Them PSKrieger 2 2,447 Nov-11-2020, 02:57 PM
Last Post: PSKrieger
  Rebuild LZ compression from C code via Python's LZMA module TD2 0 1,859 Apr-25-2019, 02:42 PM
Last Post: TD2
  problem with lambda and list compression Prince_Bhatia 1 2,345 Aug-06-2018, 11:50 AM
Last Post: ichabod801
  Compression/Decompression Code not working Zanbezi 3 3,689 May-10-2017, 04:46 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020