[Numpy-discussion] Initialization of array?
Konrad Hinsen
hinsen at cnrs-orleans.fr
Thu Nov 30 09:25:36 EST 2000
> I had another look at the definition of "ones" and of another routine
> I frequently use: arange. It appears that even without rewriting them
> in C, some speedup can be achieved:
>
> - in ones(), the + 1 should be done "in place", saving about 15%, more
> if you run out of processor cache:
I'd also try assignment in place:
def ones(shape, typecode='l', savespace=0):
a = zeros(shape, typecode, savespace)
a[len(shape)*[slice(0, None)]] = 1
return a
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the NumPy-Discussion
mailing list