Weak Lists?
Michael Chermside
mcherm at destiny.com
Wed Jan 16 13:39:16 EST 2002
>> 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.
Actually, I didn't think it mattered whether the uplinks or the
downlinks were the weak ones. In either case, you have the same number
of weakref's...
Oh <slaps forehead> of course! If I implemented as I described, then
everything but the root of my tree would disapear! So it's the uplinks
which should be weak, not the downlinks.
-- Michael Chermside
More information about the Python-list
mailing list