[Numpy-discussion] "import numpy" is slow
Andrew Dalke
dalke@dalkescientific....
Wed Jul 30 19:19:53 CDT 2008
On Jul 30, 2008, at 10:51 PM, Alan McIntyre wrote:
> I suppose it's necessary for providing the test() and bench()
> functions in subpackages, but I that isn't a good reason to impose
> upon all users the time required to set up numpy.testing.
I just posted this in my reply to Stéfan, but I'll say it again here.
numpy defines
numpy.test
numpy.bench
and
numpy.testing.test
The two 'test's use the same implementation. This is a likely
unneeded duplication and one should be removed. The choice depends on
if people think the name should be 'numpy.test' or 'numpy.testing.test'.
BTW, where's the on-line documentation for these functions? They are
actually bound methods, and I wondered if the doc programs handle
them okay.
If they should be top-level functions then I would prefer the be
actual functions to hide an import. In that case, replace
from testing import Tester
test = Tester().test
with
def test(label='fast', verbose=1, extra_argv=None, doctests=False,
coverage=False, **kwargs):
from testing import Tester
Tester.test(label, verbose, extra_argv, doctests, coverage, **kwargs)
or something similar. This would keep the API unchanged (assuming
those are important in the top-level) and reduce the number of imports.
Else I would keep/move them in 'numpy.testing' and require that if
someone wants to use 'test' or 'bench' then to get them after a 'from
numpy import testing'.
> Thanks for taking the time to find those; I just removed the unused
> glob and delayed the import of shlex, difflib, and inspect in
> numpy.testing.
Thanks!
Andrew
dalke@dalkescientific.com
More information about the Numpy-discussion
mailing list