power of explicit self?

Carl Banks pavlovevidence at gmail.com
Mon Dec 14 07:56:12 EST 2009


On Dec 12, 12:20 pm, Fire Crow <m... at firecrow.com> wrote:
> > It's not implemented in the compiler. There's a place in the runtime
> > for invoking a method where the object is inserted at the beginning
> > of the parameter list. IIRC, that's done by wrapping the function
> > object.
>
> This is the source of Objects/methodobject.c it look like this is
> where
> self is added to the argument list, but I'll have to do some more
> digging.

No, not really.  That code sets the self argument only for functions
implemented in C.

The code that implements self behavior for Python methods is mostly
found in the file classobject.c.  Basically whenever a method is
accessed through an object, the object creates an instancemethod for
it.  The instancemethod type is defined in classobject.c.


Carl Banks



More information about the Python-list mailing list