or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

block-format.mdframe-format.mdindex.mdstream-format.md
tile.json

tessl/pypi-lz4

LZ4 Bindings for Python providing high-performance lossless data compression with frame and block format support

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/lz4@4.4.x

To install, run

npx @tessl/cli install tessl/pypi-lz4@4.4.0

index.mddocs/

LZ4

LZ4 Bindings for Python providing high-performance lossless data compression with both frame format and block format specifications. This library delivers a drop-in alternative to Python's standard library compression modules (zlib, gzip, bzip2, LZMA) with a compatible API that includes context managers and file handler support.

Package Information

  • Package Name: lz4
  • Language: Python
  • Installation: pip install lz4

Core Imports

import lz4

For frame format compression (recommended):

import lz4.frame

For block format compression (low-level):

import lz4.block

For experimental stream format:

import lz4.stream

Basic Usage

import lz4.frame

# Simple compression and decompression
data = b"Hello, World!" * 1000
compressed = lz4.frame.compress(data)
decompressed = lz4.frame.decompress(compressed)

# File handling with context manager
with lz4.frame.open('data.lz4', 'wb') as f:
    f.write(b"Large amounts of data...")

with lz4.frame.open('data.lz4', 'rb') as f:
    content = f.read()

Architecture

The lz4 package provides three compression approaches:

  • Frame Format: Production-ready container format with metadata, checksums, and interoperability guarantees
  • Block Format: Low-level compression of individual data blocks without container overhead
  • Stream Format: Experimental streaming compression with double-buffer strategy (unmaintained)

All operations are thread-safe with GIL-releasing implementations optimized for performance. The library follows Python's standard compression module patterns for compatibility.

Capabilities

Version Information

Access to package and library version information.

lz4.__version__: str
lz4.VERSION: str
def lz4.library_version_number() -> int: ...
def lz4.library_version_string() -> str: ...

Frame Format Compression

Production-ready compression using the LZ4 frame format with full interoperability, metadata support, and extensive configuration options. This is the recommended interface for most use cases.

def lz4.frame.compress(data, **kwargs) -> bytes: ...
def lz4.frame.decompress(data, **kwargs) -> bytes: ...
def lz4.frame.open(filename, mode, **kwargs) -> LZ4FrameFile: ...

class lz4.frame.LZ4FrameCompressor: ...
class lz4.frame.LZ4FrameDecompressor: ...
class lz4.frame.LZ4FrameFile: ...

Frame Format

Block Format Compression

Low-level block compression without container format overhead. Provides direct access to LZ4 block compression with support for dictionaries and flexible compression modes.

def lz4.block.compress(data, **kwargs) -> bytes: ...
def lz4.block.decompress(data, **kwargs) -> bytes: ...

class lz4.block.LZ4BlockError(Exception): ...

Block Format

Stream Format Compression

Experimental streaming compression interface with double-buffer strategy. Warning: This module is unmaintained and not included in distributed wheels.

class lz4.stream.LZ4StreamCompressor: ...
class lz4.stream.LZ4StreamDecompressor: ...

class lz4.stream.LZ4StreamError(Exception): ...

Stream Format