NumPy loop efficiency

Konrad Hinsen hinsen at cnrs-orleans.fr
Fri Mar 30 05:27:18 EST 2001


"Sébastien de Menten" <sdementen at hotmail.com> writes:

> I was wondering if writing the following statement with NumPy arrays z,a,b
> and c:
> z = a + b + c

Two loops plus creation of a temporary array.

> And if
> a[:]=cos(a)+sin(a)
> creates temporary variables or assigns directly the result (like
> a[i]=cos(a[i])+sin(a[i])

It does create a temporary array. Getting rid of this would be a lot
of work, array expressions would have to use lazy evaluation.
-- 
-------------------------------------------------------------------------------
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 Python-list mailing list