Install & Compatibility
Where this runs
tested against v2.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 1.426s · 177.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 8.6s · import 1.334s · 170MB
179MB installed
● package 179MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
recursive_diff
✓ from recursive_diff import recursive_diff
✗ from recursive_diff import diff_objects
As of v2.0.0, the `diff_objects` and `diff_strings` functions were removed. Use `recursive_diff` directly for all data structure comparisons.
This quickstart demonstrates how to compare two complex Python dictionaries using `recursive_diff` and interpret the resulting list of operation dictionaries.
from recursive_diff import recursive_diff
obj1 = {
"name": "Alice",
"details": {"age": 30, "city": "New York", "preferences": {"color": "blue"}},
"items": ["apple", "banana"],
"tags": {"active": True}
}
obj2 = {
"name": "Bob",
"details": {"age": 31, "city": "London", "preferences": {"color": "red"}},
"items": ["apple", "cherry"],
"tags": {"active": True, "premium": True}
}
diff = recursive_diff(obj1, obj2)
# The diff is a list of operation dictionaries
# Example output structure:
# [
# {'op': 'change', 'path': ['name'], 'old': 'Alice', 'new': 'Bob'},
# {'op': 'change', 'path': ['details', 'age'], 'old': 30, 'new': 31},
# {'op': 'change', 'path': ['details', 'city'], 'old': 'New York', 'new': 'London'},
# {'op': 'change', 'path': ['details', 'preferences', 'color'], 'old': 'blue', 'new': 'red'},
# {'op': 'remove', 'path': ['items', 1], 'old': 'banana'},
# {'op': 'add', 'path': ['items', 1], 'new': 'cherry'},
# {'op': 'add', 'path': ['tags', 'premium'], 'new': True}
# ]
print(diff)
Errors
Common errors & fixes
AttributeError: module 'recursive_diff' has no attribute 'diff_objects'
You are attempting to call the `diff_objects` function, which was removed in `recursive-diff` version 2.0.0.
fixUpdate your code to use the main `recursive_diff` function directly. Ensure it is imported as `from recursive_diff import recursive_diff` and called like `recursive_diff(obj1, obj2)`.
ImportError: cannot import name 'diff_objects' from 'recursive_diff' (path/to/recursive_diff/__init__.py)
You are trying to import `diff_objects` (or `diff_strings`), which is no longer exposed directly from the `recursive_diff` package since version 2.0.0.
fixChange your import statement to `from recursive_diff import recursive_diff`. The main function now handles all types of comparisons.
TypeError: 'set' objects are not subscriptable
Attempting to create a diff on a data structure containing sets directly when the library's pathing expects list-like or dict-like access. While the library handles basic elements, complex scenarios with sets might require conversion if specific element-wise diffing is desired.
fixConvert sets to lists before passing them to `recursive_diff` if order doesn't matter and you want to see individual element additions/removals. Example: `obj1_list = list(obj1_set)`.
Upgrade
Version history
2.1.0latest on PyPI · released Mar 12, 2026
Audit
Dependencies
No dependency data recorded yet.