[Python-Dev] CALL_ATTR, A Method Proposal

Guido van Rossum guido@python.org
Fri, 14 Feb 2003 13:21:08 -0500


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

The caching would have to be done by the instance object's getattr()
implementation; there are all sorts of situations where the cache
would have to be invalidated and only the instance (really, its class)
knows about that.

And note that the compiler doesn't know the type of <obj> in
<obj>.<name>(<args>).  <obj> might be a module or an extension object.

--Guido van Rossum (home page: http://www.python.org/~guido/)