Numpy Array indexing question

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Jun 25 05:00:07 EDT 2001


"Pugsley" <europax at home.com> writes:

> I accidentally found that  a[i][j][k] worked just like a[i,j,k] for
> indexing a Numpy array.  But I couldn't find it mentioned any where in the
> Numeric pdf doc.  Is it ok to use that syntax?  Thanks.

Yes. In fact, if you look at the definition of what a[i] does, and
apply this definition three times, then you will see that a[i][j][k]
must be equivalent to a[i,j,k]. However, the latter should be a bit
faster (I didn't check), because only one indexing operation is
performed.
-- 
-------------------------------------------------------------------------------
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