Weak Lists?

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Jan 16 12:11:25 EST 2002


Michael Chermside <mcherm at destiny.com> wrote in 
news:mailman.1011195137.32351.python-list at python.org:

> I would like a weak list -- a list in which the values are held with 
> weak links.
<snip>
> For those who might be interested, I want this because I am creating a 
> tree, with something sort of like this:
> 
<snip>
> ... and I thought it would be nice to let the structure clean up without 
> having to invoke the circular reference garbage collector.
> 
Fair enough, but shouldn't the childNodes list be strong references and the 
parent be a weak reference? That way you won't need a list of weak 
references and the tree will tidy itself up as soon as you release the 
ultimate parent.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list