Skip to content

Commit 2aff8c2

Browse files
fix: added length check for performance
Signed-off-by: prakhar-singh1928 <prakhar.singh1928@ibm.com>
1 parent 8805e7a commit 2aff8c2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

cpex/framework/memory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ def __eq__(self, other: Any) -> bool:
195195
if not isinstance(other, Mapping):
196196
return NotImplemented
197197

198+
# Fast-path: if lengths differ, mappings cannot be equal
199+
if len(self) != len(other):
200+
return False
201+
198202
# Compare materialized items
199203
return dict(self.items()) == dict(other.items())
200204

0 commit comments

Comments
 (0)