MCPcopy Index your code
hub / github.com/RustPython/RustPython / Hashed

Class Hashed

Lib/test/test_dict.py:504–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502 def test_setdefault_atomic(self):
503 # Issue #13521: setdefault() calls __hash__ and __eq__ only once.
504 class Hashed(object):
505 def __init__(self):
506 self.hash_count = 0
507 self.eq_count = 0
508 def __hash__(self):
509 self.hash_count += 1
510 return 42
511 def __eq__(self, other):
512 self.eq_count += 1
513 return id(self) == id(other)
514 hashed1 = Hashed()
515 y = {hashed1: 5}
516 hashed2 = Hashed()

Callers 2

Calls

no outgoing calls

Tested by 2