Skip to content

Commit

Permalink
slight optimization of TreeResult len
Browse files Browse the repository at this point in the history
  • Loading branch information
seperman committed Dec 14, 2024
1 parent 767c96c commit 5120230
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion deepdiff/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ def __getitem__(self, item):
return self.get(item)

def __len__(self):
return sum([len(i) for i in self.values() if isinstance(i, SetOrdered)]) + len([i for i in self.values() if isinstance(i, int)])
length = 0
for value in self.values():
if isinstance(value, SetOrdered):
length += len(value)
elif isinstance(value, int):
length += 1
return length


class TextResult(ResultDict):
Expand Down

0 comments on commit 5120230

Please sign in to comment.