@@ -76,6 +76,10 @@ def diff(first, second, node=None, ignore=None, path_limit=None, expand=False,
7676 ... path_limit=PathLimit([('a', 'b')])))
7777 [('add', '', [('a', {})]), ('add', 'a', [('b', 'c')])]
7878
79+ >>> from dictdiffer.utils import PathLimit
80+ >>> list(diff({'a': {'b': 'c'}}, {'a': {'b': 'c'}}, path_limit=PathLimit([('a',)])))
81+ []
82+
7983 The patch can be expanded to small units e.g. when adding multiple values:
8084
8185 >>> list(diff({'fruits': []}, {'fruits': ['apple', 'mango']}))
@@ -97,6 +101,8 @@ def diff(first, second, node=None, ignore=None, path_limit=None, expand=False,
97101 :param ignore: Set of keys that should not be checked.
98102 :param path_limit: List of path limit tuples or dictdiffer.utils.Pathlimit
99103 object to limit the diff recursion depth.
104+ A diff is still performed beyond the path_limit,
105+ but individual differences will be aggregated up to the path_limit.
100106 :param expand: Expand the patches.
101107 :param tolerance: Threshold to consider when comparing two float numbers.
102108 :param absolute_tolerance: Absolute threshold to consider when comparing
@@ -203,6 +209,9 @@ def check(key):
203209 # callees again diff function to compare.
204210 # otherwise, the change will be handled as `change` flag.
205211 if path_limit and path_limit .path_is_limit (_node + [key ]):
212+ if _first [key ] == _second [key ]:
213+ return
214+
206215 yield CHANGE , _node + [key ], (
207216 deepcopy (_first [key ]), deepcopy (_second [key ])
208217 )
0 commit comments