Event triggering and weak references

Aahz Maruch aahz at netcom.com
Sun Apr 16 19:15:32 CEST 2000


In article <8dcmv0$7ub$1 at metro.ucc.usyd.edu.au>,
Ricardo Nogueira <rnog2438 at mail.usyd.edu.au> wrote:
>
>But both versions work with boundedMethods for the observer. If you change
>your main() to register(a, "x" , objY.msg) it will keep objY from being
>garbageCollected if we clear any other references to it. It is necessary to
>always call unregister before the "last" pointer to objY is cleared. Not
>very nice.
>
>How can we read objY reference count?
>If we come to know this number, compare to the number of boundedMessages we
>have for it, we can conclude if it is garbage and clear its references
>instead of calling its methods.

With the partial exception of the various garbage collection patches,
the Python model is that the programmer is responsible for managing
references.  If there are no references pointing at an object, the
object gets automatically cleaned up.  The Python scope model makes this
fairly easy, as long as you don't have any pure circular references.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"First one back from the bathroom gets to be the bottom."



More information about the Python-list mailing list