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