Diff is a library to calculate deltas between structured data.
- Calculate detla(s)
- Rebuild state from delta(s)
- JSON
- YAML
- XML
- TOML
import diff
old = {"name": "David"}
new = {"name": "Alex"}
deltas = diff.diff(new=new, old=old)
for delta in deltas:
print(delta)Output
Operation(op='modified', path='$.name', new_value='Alex', old_value='David')
import diff
old = {"name": "David"}
new = {"name": "Alex"}
deltas = diff.diff(new=new, old=old)
rebuild_new = diff.patch(base=old, deltas=deltas)
assert rebuild_new == oldpoetry add git+https://github.com/includeamin/diff.git#tag