On 8/23/06, K.S.Sreeram <[EMAIL PROTECTED]> wrote:
No, not as the language stands now.
But we don't know statically what the globals will be. You can import a module and put something in its global namespace externally. That is done after load time or compile time.
-Brett
Hi all,
I noticed in Python/ceval.c that LOAD_GLOBAL uses a dictionary lookup,
and was wondering if that can be optimized to a simple array lookup.
No, not as the language stands now.
If i'm right there are 3 kinds of name lookups: locals, outer
scopes(closures), and globals. (not counting attribute lookup). Locals
are identified by, either the presence of assignments, or their presence
in the arg list. So all name lookups can be classified into the 3 types
at compile/load time.
Since we know, at load time, which names are global.. Can't we simply
build a global name table and replace LOAD_GLOBALs with a lookup at the
corresponding index into the global name table?
But we don't know statically what the globals will be. You can import a module and put something in its global namespace externally. That is done after load time or compile time.
-Brett
_______________________________________________ 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