[Python-Dev] CALL_ATTR, A Method Proposal

Glyph Lefkowitz glyph@twistedmatrix.com
Fri, 14 Feb 2003 14:13:46 -0600


On Friday, February 14, 2003, at 12:15 PM, Skip Montanaro wrote:

> I thought one thing Glyph was trying to address was the single-use 
> nature of
> the instancemethod object.  Once it's been created, can't you just 
> cache it
> in the instance for later reuse?  When it's needed, you borrow it from 
> the
> instance, use it, then put it back (assuming the slot in the instance 
> is
> still empty, otherwise you DECREF it).  I think that would make it 
> thread
> safe.

But this would merely be trading space for speed, where neither is 
necessary.  What I'm 	proposing (and I think what Guido already had on 
his list) is that the instancemethod object never be created, as you 
can optimize the syntax to mean "call this method" rather than "get 
this attribute, call the result".