Re: [Python-Dev] weakref enhancements

2006-09-29 Thread tomer filiba
this may still be premature, but i see people misunderstood the purpose. weakattrs are not likely to be used "externally", out of the scope of the object. they are just meant to provide an easy to use means for not holding cyclic references between parents and children. many graph-like structures

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Greg Ewing
Raymond Hettinger wrote: > Also, I question the utility of maintaining a weakref to a method or > attribute instead of holding one for the object or class. As long as > the enclosing object or class lives, so too will their methods and > attributes. So what is the point of a tighter weakref gr

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Bob Ippolito
On 9/28/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > There are *definitely* use cases for keeping bound methods around. > > > > Contrived example: > > > >one_of = set([1,2,3,4]).__contains__ > >filter(one_of, [2,4,6,8,10]) > > ISTM, the example shows the (undisputed) utility of regu

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Raymond Hettinger
> There are *definitely* use cases for keeping bound methods around. > > Contrived example: > >one_of = set([1,2,3,4]).__contains__ >filter(one_of, [2,4,6,8,10]) ISTM, the example shows the (undisputed) utility of regular bound methods. How does it show the need for methods bound weakly t

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Bob Ippolito
On 9/28/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Alex Martelli] > > >I've had use cases for "weakrefs to boundmethods" (and there IS a > >Cookbook recipe for them), > > > Weakmethods make some sense (though they raise the question of why bound > methods are being kept when the underlying

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Raymond Hettinger
[Alex Martelli] >I've had use cases for "weakrefs to boundmethods" (and there IS a >Cookbook recipe for them), > Weakmethods make some sense (though they raise the question of why bound methods are being kept when the underlying object is no longer in use -- possibly as unintended side-effect of

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Alex Martelli
On 9/28/06, tomer filiba <[EMAIL PROTECTED]> wrote: > > I'm sceptical that these would find use in practice. > > [..] > > Also, I question the utility of maintaining a weakref to a method or > > attribute instead of holding one for the object or class. As long as > > the enclosing object or class

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread tomer filiba
> I'm sceptical that these would find use in practice.> [..]> Also, I question the utility of maintaining a weakref to a method or> attribute instead of holding one for the object or class.  As long as > the enclosing object or class lives, so too will their methods and> attributes.  So what is the

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Raymond Hettinger
> Also, I question the utility of maintaining a weakref to a method or > attribute instead of holding one for the object or class. Strike that paragraph -- the proposed weakattrs have references away from the object, not to the object. Raymond ___ Py

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Raymond Hettinger
tomer filiba wrote: > i'd like to suggest adding weak attributes and weak methods to the std > weakref > module. . . . > > i think these two features are quite useful, and being part of the > stdlib, would > provide programmers with easy-to-use solutions to object-aliveness issues. > > more i

[Python-Dev] weakref enhancements

2006-09-28 Thread tomer filiba
i'd like to suggest adding weak attributes and weak methods to the std weakrefmodule. weakattrs are weakly-referenced attributes. when the value they reference is no longer strongly-referenced by something else, the weakattrs "nullify" themselves. weakmethod is a method decorator, like classmethod