[Numpy-discussion] comments on array iteration behavior as described in current PEP draft
juenglin at cs.pdx.edu
Wed Mar 9 16:36:26 EST 2005
>From the current PEP draft:
A 1-d iterator will be defined that will walk through any array,
returning a Python scalar at each step. Order of the iteration
is the same for contiguous and discontiguous arrays. The last
index always varies the fastest
These 1-d iterators can also be indexed and set. In which
case the underlying array will be considered 1-d (but does not
have to be contiguous in memory).
(2) if <anything> contains only standard slicing (no index arrays or
boolean mask arrays), then a view is returned if using
a[<standard slicing>] while a copy is returned using the
iterator intermediary. The rule is that iterator slicing
always produces a copy.
(1) In Python parlance, an iterator is not indexable (cf. the iterator
protocol). You probably meant to say "sequence"?
(2) Why should the mapiter object not return views under the same
circumstances that array indexing operations return views? I can
see this being useful and would favor this behavior.
More information about the NumPy-Discussion