I think I have figured this out, thanks for your input.
The time comes from lazy modules related to e-mail importing on
attribute access, which is acceptable. Hence of course
why ImportError was sometime raised.
I originally was thinking that accessing __file__ was triggering some
mechanism that
En Fri, 05 Jun 2009 00:12:25 -0300, John Machin
escribió:
> (2) This will stop processing on the first object in sys.modules that
> doesn't have a __file__ attribute. Since these objects aren't
> *guaranteed* to be modules,
Definitely not guaranteed to be modules. Python itself drops non-mo
Steven D'Aprano REMOVE.THIS.cybersource.com.au> writes:
>
> On Fri, 05 Jun 2009 02:21:07 +, Steven D'Aprano wrote:
>
> > You corrected this to:
> >
> > for module in sys.modules.itervalues():
> >try:
> >path = module.__file__
> >except (AttributeError, Impor
Zac Burns wrote:
The section of code below, which simply gets the __file__ attribute of
the imported modules, takes more than 1/3 of the total startup time.
Given that many modules are complicated and even have dynamic
population this figure seems very high to me. it would seem very high
if one j
On Fri, 05 Jun 2009 02:21:07 +, Steven D'Aprano wrote:
> You corrected this to:
>
> for module in sys.modules.itervalues():
>try:
>path = module.__file__
>except (AttributeError, ImportError):
>return
>
> (1) You're not importing anything insid
En Thu, 04 Jun 2009 22:24:48 -0300, Zac Burns escribió:
The section of code below, which simply gets the __file__ attribute of
the imported modules, takes more than 1/3 of the total startup time.
Given that many modules are complicated and even have dynamic
population this figure seems very hig
On Thu, 04 Jun 2009 18:24:48 -0700, Zac Burns wrote:
> The section of code below, which simply gets the __file__ attribute of
> the imported modules, takes more than 1/3 of the total startup time.
How do you know? What are you using to time it?
[...]
> From once python starts and loads the main
Sorry, there is a typo. The code should read as below to repro the problem:
for module in sys.modules.itervalues():
try:
path = module.__file__
except (AttributeError, ImportError):
return
The section of code below, which simply gets the __file__ attribute of
the imported modules, takes more than 1/3 of the total startup time.
Given that many modules are complicated and even have dynamic
population this figure seems very high to me. it would seem very high
if one just considered the