Can someone explain this weakref behavior?

Michael Kent mrmakent at cox.net
Mon Jun 14 11:23:06 EDT 2004


"Tim Peters" <tim.one at comcast.net> wrote in message news:<mailman.874.1086976586.6949.python-list at python.org>...

> The bound methods you create become unreachable (via any strong reference)
> the instant they're added to the weak dict, so they vanish from the weak
> dict immediately after being added.  That's what a weak dict is supposed to
> do.

OK, I think I understand where you're coming from.  My
misunderstanding was that a persistant reference to the object would
keep the object alive, and thus was sufficient to keep a weak
reference to a bound method of the object alive.  But the two
references are totally independent, right?  So keeping the object
alive isn't sufficient to keeping the weak reference to a bound method
of the object alive.

Back to the drawing board...



More information about the Python-list mailing list