synchronized lists

Darrell dgallion1 at yahoo.com
Fri Jul 20 09:35:03 EDT 2001


Doesn't garbage collection prevent memory leaks like this?
The following cleaned up a mess I made.
>>> import gc
>>> gc.enable()
>>> gc.collect()
399996

This also looks promising "class WeakKeyDictionary"

Another approach is to put all the objects to keep track of in a dict.
Using the id(obj) as the key, then use that key instead of a reference
to the original obj.

--Darrell 

"Andreas Kremer" <andreas3004 at hotmail.com> wrote in message news:<9j8m49$22v$00$1 at news.t-online.com>...
> Hi,
> 
> i have the following design problem:
> 
> in different classes i have lists which consist of elements pointing to
> instances of other classes with lists. What i need to acchieve is that if an
> instance of one class is pointing towards another instance, the latter needs
> a pointer to the former in its list, too, to know who is pointing at it. The
> result would be at least two lists in each instance, one with pointers
> outwards to other instances, the other with pointer to instances which point
> to this instance.
>



More information about the Python-list mailing list