[Python-Dev] weakref enhancements

Bob Ippolito bob at redivi.com
Fri Sep 29 01:39:08 CEST 2006


On 9/28/06, Raymond Hettinger <rhettinger at ewtllc.com> 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 object is no longer in use --
> possibly as unintended side-effect of aggressive optimization).

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])

-bob


More information about the Python-Dev mailing list