Skip to main content

High-performance delta compression library with automatic algorithm selection

Reason this release was yanked:

no type definition, but works fine

Project description

xpatch-rs - Python Bindings

High-performance delta compression library for Python with automatic algorithm selection.

Installation

pip install xpatch-rs

Note: The package is named xpatch-rs on PyPI, but you import it as xpatch in your code.

Or build from source:

cd crates/xpatch-python
pip install maturin
maturin develop

Quick Start

import xpatch

# Create a delta patch
base = b"Hello, World!"
new = b"Hello, Rust!"
delta = xpatch.encode(tag=0, base_data=base, new_data=new)

# Apply the patch
reconstructed = xpatch.decode(base_data=base, delta=delta)
assert reconstructed == new

# Extract metadata tag
tag = xpatch.get_tag(delta)
print(f"Tag: {tag}")

API Reference

encode(tag, base_data, new_data, enable_zstd=True) -> bytes

Creates a delta patch between base_data and new_data.

Parameters:

  • tag (int): Metadata tag to embed (0-15 for no overhead, larger values supported)
  • base_data (bytes): Original data
  • new_data (bytes): New data
  • enable_zstd (bool): Enable zstd compression (default: True)

Returns: bytes - The encoded delta patch

decode(base_data, delta) -> bytes

Reconstructs new_data from base_data and a delta patch.

Parameters:

  • base_data (bytes): Original data
  • delta (bytes): Delta patch created by encode()

Returns: bytes - The reconstructed new data

Raises: ValueError if delta is invalid

get_tag(delta) -> int

Extracts the metadata tag from a delta patch without decoding.

Parameters:

  • delta (bytes): Delta patch

Returns: int - The embedded tag

Raises: ValueError if delta is invalid

Performance

xpatch achieves exceptional compression ratios on real-world data:

  • 99.8% compression on typical code changes
  • 2 byte median delta for sequential edits
  • Instant decoding (<1µs for most patches)
  • 40-55 GB/s throughput for encoding

Use Cases

Perfect for:

  • Version control systems
  • Document synchronization
  • Incremental backups
  • Network-efficient updates
  • Real-time collaborative editing

License

This project is dual-licensed:

See LICENSE-AGPL.txt and LICENSE-COMMERCIAL.txt for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpatch_rs-0.3.0.tar.gz (113.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xpatch_rs-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl (746.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

File details

Details for the file xpatch_rs-0.3.0.tar.gz.

File metadata

  • Download URL: xpatch_rs-0.3.0.tar.gz
  • Upload date:
  • Size: 113.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.10.2

File hashes

Hashes for xpatch_rs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 af80a9f6e6df3e6a6a38a6c52cd8e6b04aeb25612ccc608567fb36051b9b4cb2
MD5 ebca2ebc631342d6b0a1009b3ecbf6d0
BLAKE2b-256 1a5cdf4704cf654159a377691779feaf64bf187fb07f4d67d410325950c50602

See more details on using hashes here.

File details

Details for the file xpatch_rs-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for xpatch_rs-0.3.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 19f21d7407ed2d9ef090ad1038397ad6c00fbfe1edf2bde11512e700d9ac2e6c
MD5 241e7d011611757b766cbb35bb861f68
BLAKE2b-256 209bd365dbd04794bcb9926dcba73f25875cfdbbf7f28b9d7a070474e7253f7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page