id() collisions on bound methods [was: metaclass and customization with parameters]

Alex Martelli aleaxit at yahoo.com
Thu Oct 7 00:47:55 EDT 2004


Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:

> Jeff Epler wrote:
> > In the Olden Days, "caching" bound methods would have led to cycles
> > that were never collected.  Nowadays, there's a cyclic GC collector,
> > so if that was the killer for this idea maybe it's worth revisiting.
> 
> Alternatively, creation of the bound method could be skipped
> altogether in the case where it's going to be immediately called.
> This could be achieved by having
> 
>     obj.meth(args)
> 
> generate a single CALL_METHOD opcode instead of an attribute
> lookup followed by a call.

Heh, I was musing about just this sort of thing earlier in another
thread (about Smalltalk 'message passing' vs Python's method access) --
but then on this very thread I posted some timing results that suggets
there's little to be gained in saving the boundmethod object creation
(or equivalently caching the boundmethod).  If we could somehow save the
_lookup_ overhead... but I don't think CALL_METHOD would help there (if
I'm just not seeing some possibility I'd love to be told about it!-).


Alex



More information about the Python-list mailing list