Steven Elliott wrote:

> a pyc file referencing a global in a module may
> have been compiled with a different version of that module (that is
> "some_module.some_global" can't compiled to single fixed index since
> stuff may shift around in "some_module").

Not sure I quite follow that. Since the code in the .pyc
file is what sets the module up in the first place, it can
set up the array to suit its own use of global symbols.
The only way this could go wrong was if you extracted
the code out of a function compiled for one module and
surgically implanted it in another, but if you're hacking
at that level you deserve what you get.

I think it's actually possible to combine all the ideas
suggested so far. Builtins are assigned predefined indexes
for a particular bytecode version, and each module assigns
indexes its own way for other globals it uses. Builtins
can have dedicated opcodes which perform a fast check for
shadowing in the module and builtin arrays. Everything
goes as fast as possible while still allowing anything
to be overridden.

Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to