Replacement for locals() ???

Harald Massa cpl.19.ghum at
Sat Jul 31 00:01:53 CEST 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 
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" @
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.


More information about the Python-list mailing list