Skip to content

Commit cbe80b0

Browse files
committed
Use reversed(range) is recommended over range with negative step
https://mail.python.org/pipermail/python-ideas/2013-October/023733.html
1 parent 3206a73 commit cbe80b0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

jsonpatch.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ def compare_list(path, src, dst):
323323
'path': '/'.join(current),
324324
'value': dst[idx]}
325325
elif lsrc > ldst:
326-
# more effective than reversed(range(ldst, lsrc))
327-
for idx in range(lsrc - 1, ldst - 1 , -1):
326+
for idx in reversed(range(ldst, lsrc)):
328327
yield {'op': 'remove', 'path': '/'.join(path + [str(idx)])}
329328

330329
return cls(list(compare_dict([''], src, dst)))

0 commit comments

Comments
 (0)