NumPy loop efficiency

Konrad Hinsen hinsen at cnrs-orleans.fr
Fri Mar 30 07:11:31 EST 2001


Carlos Alberto Reis Ribeiro <cribeiro at mail.inet.com.br> writes:

> The intermediate array is not really needed, but the python expresion 
> evaluator have no way to know it. However, something like the ufuncs could 
> be used. For instance, something like this could be done (the names are 
> just examples):

Something like that (but not entirely) is possible but little known:

     Numeric.add(a, b, c)

does the same as

     c = a + b

but storing the result in the preallocated array c (which must of
course have the right dimensions). And c can well be a or b, in which
case the data is overwritten. By using only these functions, many
temporary arrays can be avoided, but at the cost of producing
unreadable code.
-- 
-------------------------------------------------------------------------------
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