Re: [Numpy-discussion] numpy speed question

2010-12-01 Thread Jean-Luc Menut
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 arra

Re: [Numpy-discussion] numpy speed question

2010-11-26 Thread Francesc Alted
A Thursday 25 November 2010 11:13:49 Jean-Luc Menut escrigué: > 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 a

Re: [Numpy-discussion] numpy speed question

2010-11-26 Thread Bruce Sherwood
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 arguments and are much slower than the math versions

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Gökhan Sever
On Thu, Nov 25, 2010 at 4:13 AM, Jean-Luc Menut 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,

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread David Cournapeau
On Thu, Nov 25, 2010 at 7:55 PM, Jean-Luc Menut 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 python looping. You

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Alan G Isaac
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.

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Jean-Luc Menut
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

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Dave Hirschfeld
Jean-Luc Menut 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 i i

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Ernest Adrogué
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'

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Jean-Luc Menut
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. ___ Nu

Re: [Numpy-discussion] numpy speed question

2010-11-25 Thread Sebastian Walter
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 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

[Numpy-discussion] numpy speed question

2010-11-25 Thread Jean-Luc Menut
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