[Numpy-discussion] (no subject)

Rob W. W. Hooft rob at hooft.net
Fri Dec 1 01:15:01 CST 2000


>>>>> "s" == szport  <szport at runet.com> writes:


 s> Is the following definition faster or not?

 s> def ones(shape, typecode=\'l\', savespace=0):
 s>    a = zeros( (product(shape),), typecode, savespace)
 s>    a[:] = 1
 s>    a.shape = shape
 s>    return a

This is yet another way to write a[...]=1 manually via a small
detour. For small arrays (size 10...1000) it is about twice slower
than writing [...] (0.1ms slower per call on my workstation).

Rob

-- 
=====   rob at hooft.net          http://www.hooft.net/people/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========



More information about the Numpy-discussion mailing list