[Python-Dev] Draft proposal: Implicit self in Python 3.0 (original) (raw)

Thomas Wouters thomas at xs4all.net
Sun Jan 8 16:58:16 CET 2006


On Sun, Jan 08, 2006 at 07:35:53AM -0800, Ralf W. Grosse-Kunstleve wrote:

IIUC, "self" is first looked up in the local dictionary.

No. Local variables are stored in a tuple (more or less,) and indexed by, er, index. Loading a local variable onto the stack is a fairly fast operation.

Please try the code below to see the performance impact. As an alternative to a copy/paste exercise try this:

wget http://cci.lbl.gov/~rwgk/python/selflookup.py python selflookup.py

The output with Python 2.4.1/Fedora3/Opteron is:

loopfunction: 13.10 loopclass: 17.11

The main difference isn't the lookup of 'self', it's the attribute retrieval of 'x' from 'self'.

-- Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!



More information about the Python-Dev mailing list