MCPcopy Index your code
hub / github.com/python/cpython / Hashed

Class Hashed

Lib/test/test_dict.py:503–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

Calls

no outgoing calls

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…