[Python-Dev] Methods and friends

M.-A. Lemburg mal@lemburg.com
Fri, 17 Sep 1999 17:53:38 +0200

Guido van Rossum wrote:
> > 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.
Oops. Correct. I should have looked a little closer. So it
already works in the first way I mentioned as improvement... your
time machine again ;-)

Marc-Andre Lemburg
Y2000:                                                   105 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/