NumPy loop efficiency

Konrad Hinsen hinsen at
Fri Mar 30 12:27:18 CEST 2001

"Sébastien de Menten" <sdementen at> 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
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-
Rue Charles Sadron                       | Fax:  +33-
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais

More information about the Python-list mailing list