DeepDiff
DeepDiff is a Python library designed for deep comparison and search operations across various Python objects and data structures, including dictionaries, lists, strings, and custom objects. It recursively identifies all differences, providing detailed reports. DeepDiff also supports hashing objects based on their content (DeepHash) and creating/applying 'deltas' to reconstruct objects. The current version is 8.6.2, and it maintains an active release cadence with frequent updates.
Warnings
- breaking A critical security vulnerability (CVE-2025-58367) was present in the Delta class, allowing class pollution leading to Denial of Service and Remote Code Execution via insecure Pickle deserialization.
- breaking The default behavior of `threshold_to_diff_deeper` changed from 0 to 0.33. This means that if less than one-third of keys intersect between two dictionaries, DeepDiff will report the entire dictionary as a `new_value` instead of detailing individual key changes.
- breaking Support for Python 3.7 was officially dropped.
- gotcha The behavior of `use_enum_value` was changed. When `use_enum_value=True`, enum comparisons now use the enum's value directly, which can alter how enum-to-string or enum-to-other-value comparisons are reported.
- gotcha The `DeepHash` functionality was changed to raise an `Exception` if it encounters a value it cannot hash, instead of silently logging the issue.
- gotcha The `ignore_type_subclasses` parameter had its behavior incorrectly reversed prior to version 7.0.0. It performed the opposite of its intended function.
- deprecated The `verify_symmetry` parameter has been deprecated.
Install
-
pip install deepdiff -
pip install "deepdiff[optimize]" -
pip install "deepdiff[cli]"
Imports
- DeepDiff
from deepdiff import DeepDiff
- DeepSearch
from deepdiff import DeepSearch
- DeepHash
from deepdiff import DeepHash
- Delta
from deepdiff import Delta
- grep
from deepdiff import grep
Quickstart
from deepdiff import DeepDiff
t1 = {'name': 'Alice', 'age': 30, 'city': 'New York'}
t2 = {'name': 'Bob', 'age': 31, 'city': 'London', 'occupation': 'Engineer'}
diff = DeepDiff(t1, t2)
print(diff)