[Numpy-discussion] objects are not aligned. Matrix and Array

Chris Colbert sccolbert@gmail....
Sat Dec 19 05:53:56 CST 2009


On Sat, Dec 19, 2009 at 6:43 AM, Charles R Harris <charlesr.harris@gmail.com
> wrote:

>
>
> On Fri, Dec 18, 2009 at 10:20 PM, Wayne Watson <
> sierra_mtnview@sbcglobal.net> wrote:
>
>> This program gives me the message following it:
>> ================Program==========
>> import numpy as np
>> from numpy import matrix
>> import math
>>
>>
> You don't want math.
>


Why do you say that? The builtins are MUCH faster than numpy for single
values:

In [1]: import math

In [2]: import numpy as np

In [3]: %timeit np.sin(1.57)
100000 loops, best of 3: 2.41 us per loop

In [4]: %timeit math.sin(1.57)
10000000 loops, best of 3: 165 ns per loop

In [6]: %timeit np.array([np.sin(1.57)])
100000 loops, best of 3: 11.5 us per loop

In [7]: %timeit np.array([math.sin(1.57)])
100000 loops, best of 3: 7.01 us per loop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091219/bfc70339/attachment.html 


More information about the NumPy-Discussion mailing list