<br><br><div><span class="gmail_quote">On 8/23/06, <b class="gmail_sendername">K.S.Sreeram</b> &lt;<a href="mailto:sreeram@tachyontech.net">sreeram@tachyontech.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br><br>I noticed in Python/ceval.c that LOAD_GLOBAL uses a dictionary lookup,<br>and was wondering if that can be optimized to a simple array lookup.</blockquote><div><br>No, not as the language&nbsp; stands now.<br></div>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If i'm right there are 3 kinds of name lookups: locals, outer<br>scopes(closures), and globals. (not counting attribute lookup). Locals
<br>are identified by, either the presence of assignments, or their presence<br>in the arg list. So all name lookups can be classified into the 3 types<br>at compile/load time.<br><br>Since we know, at load time, which names are global.. Can't we simply
<br>build a global name table and replace LOAD_GLOBALs with a lookup at the<br>corresponding index into the global name table?</blockquote><div><br>But we don't know statically what the globals will be.&nbsp; You can import a module and put something in its global namespace externally.&nbsp; That is done after load time or compile time.
<br></div><br>-Brett<br></div>