On Thursday, 1 March 2018 22:44:59 UTC, Rob Gaddi wrote:
> On 03/01/2018 02:24 PM, Lawrence D’Oliveiro wrote:
> > On Thursday, March 1, 2018 at 6:44:39 PM UTC+13, Paul Rubin wrote:
> >> DOM trees are a classic example (see the various DOM modules in the
> >> Python stdlib). Non-leaf nodes have a list of child nodes, child nodes
> >> have pointers back upwards to their parent, and each child node has
> >> pointers to its left and right siblings if they exist. It's all very
> >> circular.
> > This is why you have weak refs.
> But making sure that the failure to use weakrefs doesn't memory leak the
> program into the pavement is why you have background garbage collection
> with intelligent cyclical reference breaking.
That is the worst justification for gc I have seen yet, and also the most
truthful. gc.set_debug(gc.DEBUG_LEAK) is your friend my friends.