A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-January/019845.html below:

[Python-Dev] Re: opcode performance measurements

[Python-Dev] Re: opcode performance measurementsSamuele Pedroni Samuele Pedroni" <pedroni@inf.ethz.ch
Thu, 31 Jan 2002 22:02:23 +0100
From: Jeremy Hylton <jeremy@alum.mit.edu>
> >>>>> "SP" == Samuele Pedroni <pedronis@bluewin.ch> writes:
> 
>   SP> Hi. Q about PEP 267 Does the PEP mechanims adress only
>   SP> import a
>   SP> use a.x
> 
>   SP> cases. How does it handle things like
>   SP> import a.b
>   SP> use a.b.x
> 
> You're a smart guy, can you tell me?  :-).  Seriously, I haven't
> gotten that far.
> 
> 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".
> 
> The globals array (dict-list hybrid, technically) has the publicly
> visible binding for "mod" but also has an internal binding for
> "mod.sub" and "mod.sub.attr".  Every module or submodule attribute in
> a function gets an internal slot in the globals.  The internal slot
> gets initialized the first time it is used and then shared by all the
> functions in the module.
> 
> So I think this case isn't special enough to need a special case.
> 

 OK, I stated the wrong question.  What happens if I do the following:

import a.b

def f():
   print a.b.x
   a.g()
   print a.b.x

f()

Now a.g() change a.b from a submodule to an object with a x attribute.
Maybe this case does not make sense, but the point is that the PEP
is quite vague about imported stuff.

Samuele (more puzzled than smart).






RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4