[Michael Hudson] > ... > One way of getting _Py_RefTotal out of sync is resurrecting objects in > __del__ methods. Oops! That's right: """ from sys import gettotalrefcount as g class C: def __del__(self): alist.append(self) alist = [] c1, c2, c3 = C(), C(), C() del c1, c2, c3 while 1: print g(), len(alist), del alist[:] """ g() goes up by 3 each time around the loop. /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, * but _Py_NewReference bumped it again, so that's a wash. Heh. If you ignore the new reference(s) that resurrected the thing, I suppose that would be true. It should (2.3.2) do _Py_DEC_REFTOTAL; to make up for the extra increment done by _Py_NewReference; likewise in slot_tp_del (BTW, the macro expands to nothing if Py_REF_DEBUG isn't defined).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4