[Numpy-discussion] numpy speed question
Thu Nov 25 04:38:06 CST 2010
using math.cos instead of numpy.cos should be much faster.
I believe this is a known issue of numpy.
On Thu, Nov 25, 2010 at 11:13 AM, Jean-Luc Menut <email@example.com> wrote:
> Hello all,
> I have a little question about the speed of numpy vs IDL 7.0. I did a
> very simple little check by computing just a cosine in a loop. I was
> quite surprised to see an order of magnitude of difference between numpy
> and IDL, I would have thought that for such a basic function, the speed
> would be approximatively the same.
> I suppose that some of the difference may come from the default data
> type of 64bits in numpy and 32 bits in IDL. Is there a way to change the
> numpy default data type (without recompiling) ?
> And I'm not an expert at all, maybe there is a better explanation, like
> a better use of the several CPU core by IDL ?
> I'm working with windows 7 64 bits on a core i7.
> any hint is welcome.
> Here the IDL code :
> Julian1 = SYSTIME( /JULIAN , /UTC )
> for j=0,9999 do begin
> for i=0,999 do begin
> Julian2 = SYSTIME( /JULIAN , /UTC )
> print, (Julian2-Julian1)*86400.0
> % Compiled module: $MAIN$.
> The python code:
> from numpy import *
> from time import time
> time1 = time()
> for j in range(10000):
> for i in range(1000):
> time2 = time()
> print time2-time1
> In : run python_test_speed.py
> NumPy-Discussion mailing list
More information about the NumPy-Discussion