[Pythonmac-SIG] RefCount ?
Peter Sommerfeld
peter.sommerfeld@gmx.de
Mon, 3 May 1999 22:17:36 +0200
Jack Jansen wrote:
>Believe Just (and me:-): you _really_ don't want to do this. [snip]
Jack (and Just),
believe me, I fully trust your knowledge and experiance, but ... :-)
>Now in de parent __init__ you register and remember the key. Store the key in
>the children, and when you need the parent you use objectkeeper.get() to
>obtain it. In the parent __del__ do an unregister.
If I use a registration server (like your ObjectKeeper) remains one problem:
The __del__ function of the parent object will never be called because the last
reference is stored within the registration server itself (Or do I get anything
wrong here ?). This would work best if I could decrement the refcount by 1
imo.
There seem to be 2 solutions: The first is to use an explicit destroy (or
however
you call it) function, the second is to make the registration server regularly
check the refcounts of _all_ objects and del it if it falls below a certain
threshhold (2 ???). The first is what I want to avoid (rather error prone),
and the
net effect of the second is a grown up object managment unit :-(
On the other hand: the more I think about such a central unit, the more I
see it's
charme. :-)
Anyway, that all is fairly cruical for my application and I have to think about
it carefully.
thanks a lot
-- Peter