Referencing a container object's attributes
Alex Martelli
aleaxit at yahoo.com
Sun Mar 25 11:53:25 EST 2001
"Dave Cole" <djc at object-craft.com.au> wrote in message
news:m3ae6azeuc.fsf at vole.object-craft.com.au...
[snip]
> Tim> One question: does the circularity inherent in the above (in
> Tim> which a reference to the container object is placed in an
> Tim> attribute of each containee) have any potential for causing
> Tim> problems - particularly since I want to pickle the container
> Tim> objects?
>
> You should be able to pickle the container, but you will have to
> manually remove all of the circular references yourself when you want
> to free the object(s).
>
> In Python 2.x I understand that the garbage collector can detect and
> handle circular references.
...and in 2.1 you can have WEAK references in one of the two
directions (typically, for the child->parent backlink) to avoid
needing garbage collection, too.
Alex
More information about the Python-list
mailing list