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

Steve Holden steve at holdenweb.com
Thu Oct 7 20:38:51 CEST 2004


Alex Martelli wrote:

> 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!-).
> 
> 

I seem to remember that the sprint at the first PyCon spent some time 
considering how this might be done, but that even such luminaries as Ka 
Ping and Guido eventually had to admit that it was a hard problem.

regards
  Steve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119




More information about the Python-list mailing list