Design thought for callbacks

Chris Angelico rosuav at gmail.com
Sun Feb 22 03:17:55 EST 2015


On Sun, Feb 22, 2015 at 6:52 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> What I mean, though, is that you shouldn't think you need to create
> object destructors where you routinely set all members to None.

Sure, not *routinely*. It'd be a special case where it's not
specifically a destructor, and its job is to break a reference cycle.
For instance, you might have a close() method that clears out a bunch
of references, which will then allow everything to get cleaned up
promptly. Or (a very common case for me) a callback saying "remote end
is gone" (eg on a socket) might wipe out the callbacks, thus removing
their refloops.

ChrisA



More information about the Python-list mailing list