[Python-Dev] Re: opcode performance measurements

Gordon McMillan gmcm@hypernet.com
Thu, 31 Jan 2002 19:51:50 -0500

On 31 Jan 2002 at 6:12, Jeremy Hylton wrote:

> import mod.sub
> creates a binding for "mod" in the global namespace
> The compiler can detect that the import statement is
> a package import -- and mark "mod.sub" as a
> candidate for optimization.  A use of "mod.sub.attr"
> in function should be treated just as "mod.attr". 

How can the compiler tell it's a package import?

It's bad practice, but people write "import mod.attr" all the time. Heck, Marc-Andre tricks import so that pkg.mod is really pkg.attr where the attr turns into a 
mod when accessed. No problem, since it's only import that cares what it is. By the time it's used it's always global.attr.attr....

-- Gordon