Working around a lack of 'goto' in python

Terry Reedy tjreedy at
Wed Mar 10 17:59:43 CET 2004

"Isaac To" <kkto at> wrote in message
news:7ismggofrt.fsf at
> >>>>> "Jeff" == Jeff Epler <jepler at> writes:
>     Jeff> Are you certain that calling a function allocates a dictionary?
>     Jeff> function's locals are stored as indices in a C array unless a
>     Jeff> function uses bare exec.  I'm not sure what a dictionary is
>     Jeff> for.
> You mean a function which calls the locals() function is byte-compiled
> differently from a function that won't call locals()?

Of course.  One has a call to the locals() function and the other does not.
Note that writing to the dict returned by locals() is *NOT* guaranteed to
affect the local namespace that the dict is a copy of.  Specifics can be
version dependent, as revealed by disassembly with the dis module.

Terry J. Reedy

More information about the Python-list mailing list