This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients a-feld, deekay, pablogsal, tim.peters
Date 2020-04-20.21:54:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587419670.27.0.592549926567.issue40312@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-04-20 21:54:30tim.peterssetrecipients: + tim.peters, pablogsal, a-feld, deekay
2020-04-20 21:54:30tim.peterssetmessageid: <1587419670.27.0.592549926567.issue40312@roundup.psfhosted.org>
2020-04-20 21:54:30tim.peterslinkissue40312 messages
2020-04-20 21:54:30tim.peterscreate