No project description provided
Project description
quickdiff
quickdiff
is a python library for quickly finding nested differences between two python objects.
Usage:
from quickdiff import *
a = {1: 1, 2: 2, 3: [3], 4: 4}
b = {1: 1, 2: 4, 3: [3, 4], 5: 5, 6: 6}
report = quickdiff(a, b)
assert report == DiffReport(
val_changes=[ValChange(path=[2], a=2, b=4)],
type_and_val_changes=[],
dict_items_added=[DictDiff(path=[], key=5, val=5), DictDiff(path=[], key=6, val=6)],
dict_items_removed=[DictDiff(path=[], key=4, val=4)],
iter_len_mismatch=[IterLenMismatch(path=[3], a_len=1, b_len=2)]
)
Diff objects (ValChange
, DictDiff
, etc) are NamedTuples for improved ergonomics and thus can be unpacked as you would any tuple:
for path, a, b in report.val_changes:
print(path, a, b)
# ([2], 2, 4)
Why not DeepDiff
I wrote this because DeepDiff is quite slow as it's written in pure Python and has a lot of features.
Quickdiff on the other hand is simple and written in Rust. The current implementation yields a 16x performance boost on my personal benchmarks.
Development
Use maturin
for development:
pip install maturin
Compile development version with:
maturin development
Run tests:
python -m unittest discover tests
Future Work
There is potential for further performance improvement down the road via parallelization and by using pyo3-ffi
to sidestep the Python runtime.
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
Built Distribution
Hashes for quickdiff-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1fd0a4704c80e4e85227db7fb2031c6291cf947c78c1d017b975f08093b9643 |
|
MD5 | 83114fa957414bd01e9136042ce63048 |
|
BLAKE2b-256 | f375cfd2ec276715159f01a881b1e68b9aa7ebaafbc7dc7c9d6d7469c75feffd |