[SciPy-user] Speed differences in sqrt calculation: what is good to know
Lubos Vrbka
lists@vrbka....
Thu Jun 12 10:16:25 CDT 2008
Ivo Maljevic wrote:
> It looks like the same topic, that is, the difference in speed between numpy
> and scipy.
>
> There are all sorts of differences that I'm seeing while learning
> scipy/numpy/python. Also an interesting one,
> but probably with negligible impact:
>
> In [1]: import math
> In [2]: %timeit math.sqrt(2.2)
> 1000000 loops, best of 3: 327 ns per loop
> In [3]: %timeit math.sqrt(2.2)
> 1000000 loops, best of 3: 321 ns per loop
> In [4]: %timeit math.sqrt(2.2)
> 1000000 loops, best of 3: 323 ns per loop
>
> versus:
>
> In [1]: from math import sqrt
> In [2]: %timeit sqrt(2.2)
> 1000000 loops, best of 3: 245 ns per loop
> In [3]: %timeit sqrt(2.2)
> 1000000 loops, best of 3: 248 ns per loop
> In [4]: %timeit sqrt(2.2)
> 1000000 loops, best of 3: 248 ns per loop
hm, i see similar thing for the
import numpy; numpy.linalg.solve
and
from numpy import linalg; linalg.solve
but the differences are here relatively small (negligible). it's just
probably the time involved with the name resolution machinery in
python... the discrepancy between numpy and scipy is much much larger...
best,
--
Lubos _@_"
http://www.lubos.vrbka.net
More information about the SciPy-user
mailing list