summaryrefslogtreecommitdiff
path: root/jsonpatch.py
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2017-09-10 17:15:19 +0200
committerStefan Kögl <stefan@skoegl.net>2017-09-10 19:24:48 +0200
commit3cec8a09c4b0f810028d16c8ef88f2b1837bbeb1 (patch)
tree6a4f345aa9c55e50692de005b072b23a06b19483 /jsonpatch.py
parent462c9cbbfa9b214fe71de2d9a0fe65ec2fe4a159 (diff)
downloadpython-json-patch-3cec8a09c4b0f810028d16c8ef88f2b1837bbeb1.tar.gz
Improve optimizations
Diffstat (limited to 'jsonpatch.py')
-rw-r--r--jsonpatch.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index 284e85d..705b4ed 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -801,8 +801,17 @@ class DiffBuilder(object):
if old == new:
continue
- self._item_removed(path, key, old)
- self._item_added(path, key, new)
+ elif isinstance(old, MutableMapping) and \
+ isinstance(new, MutableMapping):
+ self._compare_dicts(_path_join(path, key), old, new)
+
+ elif isinstance(old, MutableSequence) and \
+ isinstance(new, MutableSequence):
+ self._compare_lists(_path_join(path, key), old, new)
+
+ else:
+ self._item_removed(path, key, old)
+ self._item_added(path, key, new)
elif len_src > len_dst:
self._item_removed(path, len_dst, src[key])