[Numpy-discussion] order flag again

Fernando Perez Fernando.Perez at colorado.edu
Mon Mar 27 13:31:12 CST 2006


Charles R Harris wrote:

> What purpose does ascontiguous serve?

One I can think of: making sure that C code of the type

double foo(double *array,long num_elements) { ... }

can be called in C as

foo((double *)numpy_arr->data,numpy_arr->dimensions[0]);

(the dims name in C may be different, I'm not looking at code right now)

and be OK with walking the given memory region as a contiguous chunk of 
doubles, num_elements of them.

As long as foo() doesn't modify its input, this works fine and it's nice to 
have such guarantees: it makes writing extension code a lot easier.

Cheers,

f




More information about the Numpy-discussion mailing list