On Feb 24, 2015, at 4:19 PM, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote:

> random...@fastmail.us wrote:
>> On Tue, Feb 24, 2015, at 00:20, Gregory Ewing wrote:
>>> This is why I suggested registering a listener object
>>> plus a method name instead of a callback. It avoids that
>>> reference cycle, because there is no long-lived callback
>>> object keeping a reference to the listener.
>> How does that help? Everywhere you would have had a reference to the
>> "callback object", you now have a reference to the listener object.
> 
> The point is that the library can keep a weak reference
> to the listener object, whereas it can't reliably keep
> a weak reference to a bound method.

I think I see what you're talking about now.  Does WeakMethod 
(https://docs.python.org/3/library/weakref.html#weakref.WeakMethod) solve this 
problem?  Note that I can force my users to use the latest stable version of 
python at all times, so WeakMethod IS available to me.

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to