[Python-Dev] Methods and friends

Guido van Rossum guido@CNRI.Reston.VA.US
Fri, 17 Sep 1999 11:09:40 -0400


> It seems that for every method call the following happens:
> 1. the method is looked up in the instance dict; this fails
> 2. the method is looked up in the class dict; this succeeds
>    and returns a function
> 3. the class then turns the function into a new unbound method
> 4. the instance sees the unbound method and creates a new
>    bound method (deleting the unbound method) and returns it

Are you sure?  As far as I know, steps 3 and 4 are combined when you
do getattr on an instance: instance_getattr() calls
instance_getattr1() which calls class_lookup().  The latter doesn't
create an unbound method.  instance_getattr1() then turns it into a
bound method.

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