Skip to content

Commit d18e068

Browse files
guilhermeleobaspytorchmergebot
authored andcommitted
[dict] Implement __eq__ for dict_items (pytorch#155154)
Pull Request resolved: pytorch#155154 Approved by: https://github.com/anijain2305
1 parent 3401665 commit d18e068

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/dynamo_expected_failures/CPython313-test_ordered_dict-CPythonOrderedDictTests.test_views

Whitespace-only changes.

torch/_dynamo/variables/dicts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,3 +1371,13 @@ def view_items_vt(self):
13711371

13721372
def python_type(self):
13731373
return dict_items
1374+
1375+
def call_method(self, tx, name, args, kwargs):
1376+
# TODO(guilhermeleobas): This should actually check if args[0]
1377+
# implements the mapping protocol.
1378+
if name == "__eq__":
1379+
assert len(args) == 1
1380+
if isinstance(args[0], DictItemsVariable):
1381+
return self.dv_dict.call_method(tx, "__eq__", [args[0].dv_dict], {})
1382+
return ConstantVariable.create(False)
1383+
return super().call_method(tx, name, args, kwargs)

0 commit comments

Comments
 (0)