rdiff

raw JSON →
0.2.3 verified Fri May 01 auth: no python

A native Python implementation of the rdiff tool by librsync, providing signature, delta, and patch operations for file synchronization. Current version 0.2.3, requires Python >=3.6. Maintained irregularly; last release in 2022.

pip install rdiff
error TypeError: a bytes-like object is required, not 'str'
cause Passing a string instead of bytes to signature(), delta(), or patch().
fix
Use bytes literals (b'...') or encode your strings: data.encode('utf-8').
error AttributeError: module 'rdiff' has no attribute 'signature'
cause Outdated version or incorrect import (e.g., installed wrong package or import path).
fix
Ensure you installed rdiff (not rdiff-backup or other packages) and use from rdiff import signature.
gotcha rdiff uses a custom MD4 implementation which may be slower or less tested than standard hashlib. It was introduced in v0.2.0 because hashlib's md4 is not guaranteed to be available on all platforms.
fix No fix needed; this is internal but may affect performance.
deprecated The rdiff library has not been updated since 2022. Be aware that it may not support newer Python versions or receive bug fixes. Consider using librsync or other alternatives for production use.
fix Evaluate if rdiff meets your needs or switch to librsync bindings (e.g., pylibrsync).
gotcha The signature function expects bytes, not str. Passing a string will raise a TypeError.
fix Always encode strings to bytes before calling signature, delta, or patch: e.g., b'data' or data.encode('utf-8').

Basic usage of rdiff: signature on original data, delta on new data, and patch to reconstruct the new file.

from rdiff import signature, delta, patch

# Create signature from original file
sig = signature(b'original data')

# Compute delta between signature and new file
d = delta(sig, b'new data with changes')

# Apply delta to original data to get new data
new_data = b'original data'
patched = patch(new_data, d)
print(patched)