[SciPy-user] NumPy vs. SciPy and other speed comparisons
Gael Varoquaux
gael.varoquaux@normalesup....
Wed Jun 11 03:39:27 CDT 2008
On Wed, Jun 11, 2008 at 09:15:44AM +0200, Matthieu Brucher wrote:
> The difference in speed may be only due to the fact that the scipy modle
> has much more functions than numpy's.
Matthieux does pipoint an interesting point: import time of scipy will be
much larger than import time of numpy. You could try to run the tests in
order to get rid of import time, eg by importing once, and running the
code many times.
However, if I recall correctly, there are other differences in fonctions
between scipy and numpy. Some functions in scipy do more than the
corresponding fonctions in numpy. Here is an example:
In [1]: from scipy import sqrt as ssqrt
In [2]: from numpy import sqrt as nsqrt
In [3]: ssqrt(-1)
Out[3]: 1j
In [4]: nsqrt(-1)
Out[4]: nan
In [5]: %timeit ssqrt(-1)
10000 loops, best of 3: 37.7 µs per loop
In [6]: %timeit nsqrt(-1)
100000 loops, best of 3: 6.14 µs per loop
Maybe this is what you are seeing.
Gaël
More information about the SciPy-user
mailing list