MCPcopy Index your code
hub / github.com/numpy/numpy / ReferenceCycleInDel

Class ReferenceCycleInDel

numpy/testing/tests/test_utils.py:2113–2130  ·  view source on GitHub ↗

An object that not only contains a reference cycle, but creates new cycles whenever it's garbage-collected and its __del__ runs

Source from the content-addressed store, hash-verified

2111 """
2112
2113 class ReferenceCycleInDel:
2114 """
2115 An object that not only contains a reference cycle, but creates new
2116 cycles whenever it's garbage-collected and its __del__ runs
2117 """
2118 make_cycle = True
2119
2120 def __init__(self):
2121 self.cycle = self
2122
2123 def __del__(self):
2124 # break the current cycle so that `self` can be freed
2125 self.cycle = None
2126
2127 if ReferenceCycleInDel.make_cycle:
2128 # but create a new one so that the garbage collector (GC) has more
2129 # work to do.
2130 ReferenceCycleInDel()
2131
2132 try:
2133 w = weakref.ref(ReferenceCycleInDel())

Callers 2

__del__Method · 0.85
test_failsMethod · 0.85

Calls

no outgoing calls

Tested by 2

__del__Method · 0.68
test_failsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…