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
Roadmap
- support for sets (currently is treated as an iterator)
- parallelize for improved performance (by using
pyo3-ffi
to sidestep the Python runtime) - attribute diff checking for python objects
- support custom
__eq__()
implementations
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
quickdiff-0.1.3.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for quickdiff-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72b232d00080d7d3bb2a3ddb753540254f127cfe96ff4dc8236199c3118bcbf0 |
|
MD5 | 1ac9149a710ef14775259977b7b349a3 |
|
BLAKE2b-256 | 2e4fabb885b12bf409255b44cd2468c1fe78961f184891fb056b0ad58731eaf4 |