Replacement for locals() ???

Christian Tismer tismer at
Fri Jul 30 17:14:55 CEST 2004

Skip Montanaro wrote:

>     Harald> I read within psysco-FAQ and Jim Hugoninis IronPython paper: a
>     Harald> lot of words about "locals() being very difficult or impossible
>     Harald> to optimize"
>     Harald> AND UNTIL
>     Harald> so ... is there any convenient replacement? Of course I could do
>     Harald> {"id":id, "surename":surename} , but that would be very very
>     Harald> in-elegant.
> That's the only solution I've found so far.  Makes for rather ugly code.  If
> you have to choose, what do you want, fast or pretty? <wink>

You can have both: fast and pretty.
That's why I got interested in Bytecodehacks:
I can write locals(), but transform that into
the explicit from by introspection, and replace
the function before I use it.
(Haven't written an un-local()iser yet, but it
seems straight forward).

ciao - chris

Christian Tismer             :^)   <mailto:tismer at>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship*
14109 Berlin                 :     PGP key ->
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?

More information about the Python-list mailing list