Message366895
A simple (finalizer-only) example of what an SCC-based DAG topsort ordering would accomplish:
import gc
class C:
def __init__(self, val):
self.val = val
def __del__(self):
print("finalizing", self.val)
c, b, a = map(C, "cba")
a.next = b
b.next = c
#a.loop = a
del c, b, a
gc.collect()
That finalizes in the order a, b, c. Refcount semantics force that. But, uncomment the "a.loop = a" line, and the order changes to c, b, a. They all look exactly the same to gc, so it runs finalizers in the order they happen to appear in the list gc is crawling over. A DAG topsort ordering would force a, b, c order again. |
|
Date |
User |
Action |
Args |
2020-04-20 21:54:30 | tim.peters | set | recipients:
+ tim.peters, pablogsal, a-feld, deekay |
2020-04-20 21:54:30 | tim.peters | set | messageid: <1587419670.27.0.592549926567.issue40312@roundup.psfhosted.org> |
2020-04-20 21:54:30 | tim.peters | link | issue40312 messages |
2020-04-20 21:54:30 | tim.peters | create | |
|