Replacement for locals() ???

Harald Massa cpl.19.ghum at spamgourmet.com
Fri Jul 30 18:01:53 EDT 2004


Gabriel ,

> Are you experiencing a slow down due to using locals() or a significant 
> performance increase by using the above method? If not, why switch away 
> from locals?

I do not experience a slow down and did not measure any performance 
changes. My question orginates in three observations:

1.) Jim Hugunin writes in his OSCON Paper 
(http://www.python.org/pycon/dc2004/papers/9/) 
The greatest performance improvement comes from [...] The price of this 
optimization is that it requires disabling the locals() builtin function 
[...]

2.) Armin Rigo writes in "Known Bugs of Psyco" @ 
http://psyco.sourceforge.net/psycoguide/bugs.html:
No locals dictionary is available. The locals function always return an 
empty dictionary [...}

3.) My usage of locals() is really peripheral. I just use it to make code 
shorter and to avoid typing misstakes with variables.

So two of the greatest PythonBrains have problems in optimizing Python 
because of locals(), the most common usage of Python in my practice is 
peripheral; so just by way of precaution I am looking for a replacement.

Harald



More information about the Python-list mailing list