[Numpy-discussion] Accessing irregular sized array data from C

Sturla Molden sturla.molden at gmail.com
Wed Jul 2 15:33:20 EDT 2014


Nathaniel Smith <njs at pobox.com> wrote:

> Numpy internally does all index/stride calculations in units of bytes,
> though, so if accessing the data array directly and using strides, the only
> reliable approach is to use intp or equivalent.

If we use PyArray_STRIDES we should use npy_intp, yes, because we are
computing the address directly from a char*. It depends on how much we know
about the array in advance.

Also a C standard pendant would point out we can only assume an int will be
at least 16 bit, and we should use long to make sure it is at least 32 bit.

Sturla




More information about the NumPy-Discussion mailing list