DataDiff (Python Data Structures)

2.2.0 · active · verified Thu Apr 16

DataDiff is a Python library (version 2.2.0) designed to provide human-readable diffs of common Python data structures, including lists, tuples, sets, and dictionaries. It recursively compares nested structures and offers special handling for multi-line strings, presenting them in a unified diff format. The library also provides drop-in replacements for some `nose` assertions, displaying clear data differences upon assertion failures. The project has a slower but consistent release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `datadiff.diff` to compare two Python dictionaries, showing changes in values, lists, and new keys.

from datadiff import diff

a = dict(foo=1, bar=2, baz=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
b = dict(foo=1, bar=4, baz=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'changed', 11], qux='new')

result = diff(a, b)
print(result)

view raw JSON →