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/self_lookup.py
> python self_lookup.py

> The output with Python 2.4.1/Fedora3/Opteron is:
> 
> loop_function: 13.10
>    loop_class: 17.11

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

-- 
Thomas Wouters <[EMAIL PROTECTED]>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to