[Numpy-discussion] "import numpy" is slow
Sat Aug 2 01:13:20 CDT 2008
On Sat, Aug 2, 2008 at 00:06, David Cournapeau
> Christopher Barker wrote:
>> OK, I just installed wxPython, and whoa!
>> time python -c "import numpy"
>> real 0m2.793s
>> user 0m0.294s
>> sys 0m2.494s
>> so it's taking almost two seconds more to import numpy, now that
>> wxPython is installed. I haven't even imported it yet. importing wx
>> isn't as bad:
>> $ time python -c "import wx"
>> real 0m1.589s
>> user 0m0.274s
>> sys 0m1.000s
> Since numpy wo wx + wc import times adds up to numpy import times, this
> suggests that numpy may import wx. Which it shouldn't, obviously. There
> is something strange happening here. Please check wether wx really is
> imported when you do import numpy:
> python -c "import numpy; import sys; print sys.modules"
> And if it is, we have to know why it is imported at all when doing
> import numpy.
It isn't. The problem is on Chris's file system. Whatever is wrong
with his file system (Bill Spotz's identical problem suggests too many
temporary but unused inodes) increases the traversal of the file
system. wx has a .pth file which adds entries to sys.path. Every time
one tries to import something, the entries on sys.path are examined
for the module. So increasing the number of entries on sys.path
exacerbates the problem. But the problem really is his disk; it's not
a problem with numpy or Python or anything else.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion