Dictdiffer is a Python library designed to compute differences between dictionaries and apply patches based on those differences. It handles nested structures, lists, and sets. The current version is 0.9.0, with releases occurring on an as-needed basis.
pip install dictdifferVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `diff` to find differences between two dictionaries, `patch` to apply those changes, and `revert` to undo them. It also shows a basic example of ignoring specific keys during diffing.
Upgrade to Python 3.5 or newer, or pin `dictdiffer` to a version <0.9.0 if Python 2.x/3.4 compatibility is required (though not recommended).
Review existing code that processes diff outputs from versions prior to 0.7.0 to ensure it correctly handles the new immutable behavior. This is generally a safer approach, but could break code relying on mutable references.
Upgrade `dictdiffer` to version 0.7.1 or newer to correctly handle keys with dots.
Upgrade `dictdiffer` to version 0.8.1 or newer to ensure correct diffing and patching of set elements.
pip install dictdiffer
from dictdiffer import diff, patch, swap, revert
Use `dictdiffer.diff()` directly, as it correctly handles nested lists and other unhashable types. Example: `from dictdiffer import diff; differences = list(diff(dict1, dict2))`
Ensure the `diff_result` is applied to a destination dictionary that is consistent with the 'first' dictionary used to generate the diff, and that no intermediate changes have made list indices invalid. Verify the structure of the `diff_result` if manually generated.
No dependency data recorded yet.