[Numpy-discussion] In-place operations

Travis Oliphant oliphant at ee.byu.edu
Tue Sep 12 15:28:01 EDT 2006


Francesc Altet wrote:

>>>>Timer("a=numpy.array(100,dtype=numpy.complex128)", "import
>>>>        
>>>>
>numpy").repeat(3,10000)
>[0.19819307327270508, 0.14915895462036133, 0.14999985694885254]
>  
>
>>>>Timer("a=numpy.array(10000,dtype=numpy.complex128)", "import
>>>>        
>>>>
>numpy").repeat(3,10000)
>[0.15171599388122559, 0.14998698234558105, 0.14901280403137207]
>
>that is 15 us (in my old machine) irregardingly of the size.
>  
>
Ummm..    You are not creating empty arrays here.  You are creating a 
0-d array with a single entry. 

>[BTW, numpy.empty seems twice as slower in my machine. Why?
>  
>
>>>>Timer("a=numpy.empty(10000,dtype=numpy.complex128)", "import
>>>>        
>>>>
>numpy").repeat(3,10000)
>[0.37033700942993164, 0.31780219078063965, 0.31607294082641602]
>]
>  
>
Now, you are creating an empty array with 10000 elements in it. 

Best,

-Travis





More information about the NumPy-Discussion mailing list