[Numpy-discussion] Wanted: Numeric/NumPy compatible array creation expression

Robert kxroberto at googlemail.com
Thu Nov 23 10:44:10 CST 2006

konrad.hinsen at laposte.net wrote:
> On 23.11.2006, at 16:29, Robert wrote:
>>> that will *also* (not *only*) work under NumPy (where typecode()
>>> became dtype.char). An obvious idea is reshaping array1 and
>>> multiplying by 0., but that can become quite costly.
>> timeit if *0 is really costly ... you'll not get it really cheaper  
>> I think.
> What I expect to be costly is the reshape (resize in most  
> situations), not the multiplication. I didn't do any timings though...

its simple with:

import timeit

reshaping is usually very cheap (numpy), as only an new view with other index geometry is created. 
A (unavoidable?) copy is probably the most expensive but just test ... 


More information about the Numpy-discussion mailing list