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 datanew_data(bytes): New dataenable_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 datadelta(bytes): Delta patch created byencode()
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
Native Python bindings provide excellent performance:
- Small data (~13 bytes): ~7 µs encode, <0.1 µs decode
- Medium data (10KB): ~8 µs encode, ~0.5 µs decode
- Large data (100KB): ~12 µs encode, ~4 µs decode
- Tag extraction: <0.1 µs
Compression ratios on test data:
- 1 byte change in 10KB file: 11 bytes delta (99.89% compression)
- 1 byte change in 100KB file: 14 bytes delta (99.99% compression)
Use Cases
Perfect for:
- Version control systems
- Document synchronization
- Incremental backups
- Network-efficient updates
- Real-time collaborative editing
License
This project is dual-licensed:
- AGPL-3.0-or-later for open-source use
- Commercial license available at xpatch-commercial@alias.oseifert.ch
See LICENSE-AGPL.txt and LICENSE-COMMERCIAL.txt for details.
Links
Metadata
Release files for xpatch-rs 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xpatch_rs-0.4.2.tar.gz | 114.6 kB | Without provenance | Details for xpatch_rs-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xpatch_rs-0.4.2-cp313-cp313-manylinux_2_34_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.34+ x86-64 | Details for xpatch_rs-0.4.2-cp313-cp313-manylinux_2_34_x86_64.whl |
Total release size: 861.6 kB
Release files / xpatch_rs-0.4.2.tar.gz
| Download URL | xpatch_rs-0.4.2.tar.gz |
|---|---|
| Size | 114.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ba4ea71d5f7cc747967c4abbae2dc99df58468b19a84d29654378e5379f7123
|
|
BLAKE2b-256 checksum How to use checksums |
7817dfabaf57e6724f44a8a283b5e9da91a81781d6679b30a28945f13a2f7b16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / xpatch_rs-0.4.2-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | xpatch_rs-0.4.2-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 747.0 kB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
ad428d916e25a3aa4e3c108e1f33d0679102f73748a32c04362c7180b4dd44f8
|
|
BLAKE2b-256 checksum How to use checksums |
f128e201a7a24164ccd99b9eb06bb3eb40106303ca842e927653b525e9bcc78b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Security for xpatch-rs 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.