Le 26/11/2010 17:48, Bruce Sherwood a écrit :
Although this was mentioned earlier, it's worth emphasizing that if
you need to use functions such as cosine with scalar arguments, you
should use math.cos(), not numpy.cos(). The numpy versions of these
functions are optimized for handling array
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
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 jeanluc.me...@free.fr 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
Le 25/11/2010 11:38, Sebastian Walter a écrit :
using math.cos instead of numpy.cos should be much faster.
I believe this is a known issue of numpy.
You're right, with math.cos, the code take 4.3s to run, not as fast as
IDL, but a lot better.
___
Hi,
25/11/10 @ 11:13 (+0100), thus spake Jean-Luc Menut:
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) ?
This is probably not the issue.
And I'm
Jean-Luc Menut jeanluc.menut at free.fr writes:
I have a little question about the speed of numpy vs IDL 7.0.
Here the IDL result:
% Compiled module: $MAIN$.
2.837
The python code:
from numpy import *
from time import time
time1 = time()
for j in range(1):
for
Le 25/11/2010 11:51, Ernest Adrogué a écrit :
I'm not an expert either, but the basic idea you have to get is
that for loops in Python are slow. Numpy is not going to change
this. Instead, Numpy allows you to work with vectors and arrays
so that you need not putting loops in your code. So, you
On 11/25/2010 5:55 AM, Jean-Luc Menut wrote:
it was just a test to compare the speed of
the cosine function in IDL and numpy
The point others are trying to make is that
you *instead* tested the speed of creation
of a certain object type. To test the *function*
speeds, feed both large arrays.
On Thu, Nov 25, 2010 at 7:55 PM, Jean-Luc Menut jeanluc.me...@free.fr wrote:
Yes I know but IDL share this characteristics with numpy, and sometimes
you cannot avoid loop. Anyway it was just a test to compare the speed of
the cosine function in IDL and numpy.
No, you compared IDL looping and