DeepDiff

raw JSON →
6.2.0 verified Tue May 12 auth: no en install: verified quickstart: verified

DeepDiff is a powerful Python library for finding the deep difference between nearly any two Python objects, including dictionaries, lists, sets, and custom objects. It provides detailed, human-readable, and machine-readable output in various formats like JSON and YAML. The current stable PyPI version is 6.2.0, with active development and frequent releases, including major version 9.0.0 available on GitHub.

pip install deepdiff
error TypeError: unhashable type: 'list'
cause Attempting to compare sets or dictionaries with `ignore_order=True` where keys or set members are unhashable types like lists.
fix
Convert unhashable types to hashable equivalents (e.g., tuples from lists) before comparison, or provide a custom iterable_compare_func or set_item_diff_func that can handle the unhashable items.
error RecursionError: maximum recursion depth exceeded in comparison of two objects
cause Comparing deeply nested Python objects, exceeding Python's default recursion limit (often 1000).
fix
Increase Python's recursion limit for the current scope using sys.setrecursionlimit(new_limit) (use with caution), or restructure your data to reduce nesting where possible.
error KeyError: 'type'
cause This can occur when attempting to diff specific Python objects that DeepDiff doesn't inherently understand or when the `exclude_types` or `include_types` parameters are misused.
fix
Ensure that the objects being compared are standard Python types or well-defined custom objects. If using exclude_types or include_types, verify that the specified types are correct and accessible.
breaking Version 9.0.0 introduces breaking changes to `to_dict()` and `to_json()` methods. The `view_override` parameter is removed, replaced by `verbose_level`. Additionally, Python 3.9 support has been dropped.
fix Review calls to `to_dict()` and `to_json()`, remove `view_override` and pass `verbose_level` explicitly if needed. Ensure Python environment is 3.10+.
breaking Version 8.0.0 changed the default behavior of `threshold_to_diff_deeper`, which might alter diff results for complex nested objects. Previously, a value of 0 was default. Now, it defaults to a non-zero value, leading to different comparison depth.
fix If older behavior is desired, explicitly set `threshold_to_diff_deeper=0` when initializing `DeepDiff`.
gotcha Versions of DeepDiff prior to 8.6.1 were vulnerable to a security issue (CVE-2025-58367) in the `Delta` class, which could lead to Denial of Service and Remote Code Execution via insecure Pickle deserialization.
fix Immediately upgrade to DeepDiff 8.6.1 or later to patch the vulnerability.
gotcha When comparing collections with `ignore_order=True` (e.g., sets of dictionaries or lists), items must be hashable. If items are unhashable (e.g., lists), DeepDiff may raise a `TypeError`.
fix Ensure all items within collections compared with `ignore_order=True` are hashable. Use `DeepDiff(..., ignore_order=True, iterable_compare_func=lambda x: str(x))` or provide a custom comparison function for complex unhashable objects.
python os / libc variant status wheel install import disk
3.10 alpine (musl) cli - - 0.14s 21.8M
3.10 alpine (musl) optimize - - 0.26s 19.3M
3.10 alpine (musl) deepdiff - - 0.15s 18.9M
3.10 slim (glibc) cli - - 0.09s 23M
3.10 slim (glibc) optimize - - 0.09s 20M
3.10 slim (glibc) deepdiff - - 0.10s 19M
3.11 alpine (musl) cli - - 0.24s 24.2M
3.11 alpine (musl) optimize - - 0.24s 21.3M
3.11 alpine (musl) deepdiff - - 0.23s 20.9M
3.11 slim (glibc) cli - - 0.17s 25M
3.11 slim (glibc) optimize - - 0.18s 22M
3.11 slim (glibc) deepdiff - - 0.18s 21M
3.12 alpine (musl) cli - - 0.20s 16.0M
3.12 alpine (musl) optimize - - 0.19s 13.1M
3.12 alpine (musl) deepdiff - - 0.20s 12.7M
3.12 slim (glibc) cli - - 0.18s 17M
3.12 slim (glibc) optimize - - 0.20s 14M
3.12 slim (glibc) deepdiff - - 0.18s 13M
3.13 alpine (musl) cli - - 0.35s 15.7M
3.13 alpine (musl) optimize - - 0.19s 12.7M
3.13 alpine (musl) deepdiff - - 0.19s 12.4M
3.13 slim (glibc) cli - - 0.18s 17M
3.13 slim (glibc) optimize - - 0.18s 13M
3.13 slim (glibc) deepdiff - - 0.17s 13M
3.9 alpine (musl) cli - - 0.14s 20.9M
3.9 alpine (musl) optimize - - 0.14s 18.4M
3.9 alpine (musl) deepdiff - - 0.14s 18.1M
3.9 slim (glibc) cli - - 0.11s 22M
3.9 slim (glibc) optimize - - 0.11s 19M
3.9 slim (glibc) deepdiff - - 0.11s 19M

Demonstrates a basic deep difference between two dictionaries. The output will show added, removed, and changed items.

from deepdiff import DeepDiff

dict1 = {'a': 1, 'b': 2, 'c': {'d': 4, 'e': 5}}
dict2 = {'a': 1, 'b': 3, 'c': {'d': 4, 'f': 6}}

diff = DeepDiff(dict1, dict2)
print(diff)