A modest proposal

Christopher A. Craig com-nospam at ccraig.org
Mon Nov 19 14:32:23 CET 2001

Ype Kingma <ykingma at accessforall.nl> writes:

> There is a python to java byte code compiler that does something
> quite similar for local namespaces: it maps some known locals to the
> iloadN/istoreN instructions of the java virtual machine. I don't
> know/understand the details, so in case you want more information it
> is probably best to post at jython-dev via www.jython.org.

Actually, CPython does something similar for local namespaces.  The
issue is with global namespaces.  Local namespaces are immutable (once
you compile a function, you cannot change what names it uses), which
means it is quite easy to enumerate the variables.  

Global namespaces, OTOH, are mutable.  Even after you've included a
module, someone who imported your module can later add variables to
it.  This makes it impossible to simply use numeric indicies for them,
which is why we have this proposal, and PEPs 266 and 267.

Christopher A. Craig <com-nospam at ccraig.org>

More information about the Python-list mailing list