Re: [Anygui-devel] And another thing... (signal/kwds)
Brought to you by:
mlh
From: Joseph A K. <jk...@ea...> - 2001-10-31 16:50:52
|
Magnus Lie Hetland wrote: > > From: "Patrick K. O'Brien" <po...@or...> > > > I'm a bit confused by this latest change. Wouldn't registering a bound > > method as a signal handler be the most common case? This is how I picture > > the previous implementation's most common case: > [snip] > > Quite a common case, I agree. > > > So shouldn't the common case be the easiest to use? > > Well, it is, isn't it? You can do exactly what you did if you like. > > > And shouldn't it be made to work with weak references? > > As Joe explained, that can't be done, since the method refers to its object > with a strong reference. > > > And didn't it work with weak references prior to this change? > > It "worked", but the GC problem was there -- and it still is. There is no GC problem in either case. The "old" way, if you use a bound method as a handler then the signal code converts it into a weakref to the object and an unbound method, and throws away the original bound method object; so no strong references are retained by the signal code. The "new" way, you'd have to explicitly pass an object and an unbound method to get the same effect. I think Patrick's concern that the common case should be the simplest is very valid. I'm backing away from the changes I suggested earlier; I want to look at another alternative first. I also think (now) that it's probably never a good idea for the signal code to keep strong references to anything; if you want to prevent an object from being GC'd it's simple to keep a global reference to it somewhere. Sorry to be so fickle, but I think it's important to get this right. Cheers, -- Joe # "You know how many remote castles there are along the # gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald # (Obsolete) Linux MM docs: http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html |