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

Class TracingDict

Lib/test/test_functools.py:2670–2683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2668 import weakref
2669
2670 class TracingDict(UserDict):
2671 def __init__(self, *args, **kwargs):
2672 super(TracingDict, self).__init__(*args, **kwargs)
2673 self.set_ops = []
2674 self.get_ops = []
2675 def __getitem__(self, key):
2676 result = self.data[key]
2677 self.get_ops.append(key)
2678 return result
2679 def __setitem__(self, key, value):
2680 self.set_ops.append(key)
2681 self.data[key] = value
2682 def clear(self):
2683 self.data.clear()
2684
2685 td = TracingDict()
2686 with support.swap_attr(weakref, "WeakKeyDictionary", lambda: td):

Callers 1

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…