[Numpy-discussion] Question about flags of fancy indexed array

Anne Archibald peridot.faceted at gmail.com
Wed May 23 09:49:08 EDT 2007


On 23/05/07, Albert Strasheim <fullung at gmail.com> wrote:

> Consider the following example:

First a comment: almost nobody needs to care how the data is stored
internally. Try to avoid looking at the flags unless you're
interfacing with a C library. The nice feature of numpy is that it
hides all that junk - strides, contiguous storage, iteration, what
have you - so that you don't have to deal with it.

> Is it correct that the F_CONTIGUOUS flag is set in the case of the fancy
> indexed x? I'm running NumPy 1.0.3.dev3792 here.

Numpy arrays are always stored in contiguous blocks of memory with
uniform strides. The "CONTIGUOUS" flag actually means something
totally different, which is unfortunate, but in any case, "fancy
indexing" can't be done as a simple reindexing operation. It must make
a copy of the array. So what you're seeing is the flags of a fresh new
array, created from scratch (and numpy always creates arrays in C
order internally, though that is an implementation detail you should
not rely on).

Anne



More information about the NumPy-Discussion mailing list