<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 2, 2014 at 11:36 AM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">
<div><div class="h5">On Fri, Aug 1, 2014 at 8:22 PM, David Cournapeau <span dir="ltr"><<a href="mailto:cournape@gmail.com" target="_blank">cournape@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">
<div>On Sat, Aug 2, 2014 at 11:17 AM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">
<div>On Fri, Aug 1, 2014 at 8:01 PM, David Cournapeau <span dir="ltr"><<a href="mailto:cournape@gmail.com" target="_blank">cournape@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">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).<div>



<br></div><div>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).</div><span><font color="#888888">
<div><br></div></font></span></div></blockquote><div><br></div></div><div>I'm not sure a one time hit of 17 ms is worth fighting for ;) The problems were that both the `string` and `dis` modules were used without importing them. </div>


</div></div></div></blockquote><div><br></div></div><div>Don't fix what ain't broken ;)</div><div><br></div><div>The 17 ms is not what matters, the % is. People regularly complain about import times, and 25 % increase in import time is significant (the above timing are on my new macbook with SSD and 16 Gb RAM -- figures will easily be 1 order of magnitude worse in common situations with slower computers, slower HDD, NFS, etc...)</div>

</div></div></div></blockquote><div><br></div></div></div><div>Be interesting to compare times. Could you send along the code you used? My machine is similar except it is a desktop with 2 SSDs in raid 0.<br></div></div></div>
</div></blockquote><div><br></div><div>I just hacked numpy.lib.__init__ to use inspect instead of _inspect:</div><div><br></div><div>diff --git a/numpy/compat/__init__.py b/numpy/compat/__init__.py</div><div>index 5b371f5..57f6d7f 100644</div>
<div>--- a/numpy/compat/__init__.py</div><div>+++ b/numpy/compat/__init__.py</div><div>@@ -10,11 +10,11 @@ extensions, which may be included for the following reasons:</div><div> """</div><div> from __future__ import division, absolute_import, print_function</div>
<div><br></div><div>-from . import _inspect</div><div>+import inspect as _inspect</div><div> from . import py3k</div><div>-from ._inspect import getargspec, formatargspec</div><div>+from inspect import getargspec, formatargspec</div>
<div> from .py3k import *</div><div><br></div><div> __all__ = []</div><div>-__all__.extend(_inspect.__all__)</div><div>+__all__.extend(["getargspec", "formatargspec"])</div><div> __all__.extend(py3k.__all__) </div>
<div><br></div><div>David</div></div></div></div>