On Tue, Jul 31, 2001 at 10:51:35AM +1200, Greg Ewing wrote:
Skip Montanaro
:
The main stumbling block was that pesky "from module import *" statement. It could push an unknown quantity of stuff onto the stack
Are you *sure* about that? I'm pretty certain it can't be true, since the compiler has to know at all times how much is on the stack, so it can decide how much stack space is needed.
I think Skip meant it does an arbitrary number of load-onto-stack store-into-namespace operations. Skip, you'll be glad to know that's no longer true :) Since 2.0 (or when was it that we introduced 'import as' ?) import-* is not a special case of 'IMPORT_FROM', but rather a separate opcode that doesn't touch the stack. 'IMPORT_FROM' is now only used to push a given name from TOS onto the stack:
def eggs(): ... from stat import a, b dis.dis(eggs) ... 9 IMPORT_NAME 0 (stat) 12 IMPORT_FROM 1 (a) 15 STORE_FAST 1 (a) 18 IMPORT_FROM 2 (b) 21 STORE_FAST 0 (b) 24 POP_TOP ...
def spam(): ... from stat import * dis.dis(spam) ... 6 LOAD_CONST 1 (('*',)) 9 IMPORT_NAME 0 (stat) 12 IMPORT_STAR ...
Bloody hell, what's that LOAD_CONST doing there ? I think I found a bug ;P
Sigh... Sleep first, fix later.
--
Thomas Wouters