| 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): |
no outgoing calls
searching dependent graphs…