[Numpy-discussion] numpy speed question

Jean-Luc Menut jeanluc.menut at free.fr
Wed Dec 1 05:23:22 EST 2010

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 arguments and are much
> slower than the math versions for scalar arguments.

Yes I understand that. I just want to stress that it was not a benchmark 
(nor a critic) but a test to know if it was interesting to translate 
directly an IDL code into python/numpy before trying to optimize it (I 
know more python than IDL). I expected  to have approximatively the same 
speed for both, was surprised by the result, and wanted to know if there 
was an obvious reason besides the unoptimization for scalars.

More information about the NumPy-Discussion mailing list