
On my machine, if I use inspect instead of _inspect in numpy.compat.__init__, the import time increases ~ 25 % (from 82 ms to 99 ms). So the hack certainly still make sense, one just need to fix whatever needs fixing (I am still not sure what's broken for the very specific usecase that code was bundled for). David On Sat, Aug 2, 2014 at 5:11 AM, David Cournapeau <cournape@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:23 PM, Charles R Harris < charlesr.harris@gmail.com> wrote:
On Fri, Aug 1, 2014 at 7:59 AM, Robert Kern <robert.kern@gmail.com> wrote:
On Fri, Aug 1, 2014 at 2:54 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:
Importing inspect looks to take about 500 ns on my machine. Although It is hard to be exact, as I suspect the file is sitting in the file cache. Would probably be slower with hard disks.
Or where site-packages is on NFS.
But as the inspect module is already imported elsewhere, the python interpreter should also have it cached.
Not on a normal import it's not.
import numpy import sys sys.modules['inspect'] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'inspect'
There are two lazy imports of inspect.
You should feel free to remove whatever parts of `_inspect` are not being used and to move the parts that are closer to where they are used if you feel compelled to. Please do not replace the current uses of `_inspect` with `inspect`.
It is used in just one place. Is importing inspect so much slower than all the other imports we do?
Yes, please look at the thread I referred to. The custom inspect cut imports by 30 %, I doubt the ratio is much different today.
David