[Numpy-discussion] question about the data entry in the __array_interface__

Nathaniel Smith njs at pobox.com
Sun Apr 7 17:07:53 EDT 2013


On Sun, Apr 7, 2013 at 2:26 PM, Valentin Haenel <valentin at haenel.co> wrote:
> I know that the address is contained in the 'data' field of the
> '__array_interface__' and is either an int or a long. My guess is that
> this depends on the architecture of the system, i.e. 32 vs 64 bit
> systems.
>
> My question is: what is the correct type to use when using
> PyArg_ParseTuple to convert the value. I am currently using:
>
> k (integer) [unsigned long]
>
>     Convert a Python integer or long integer to a C unsigned long
>     without overflow checking.
>
> The reason I chose 'k' is because it seems to be the only option that
> can deal with both Python int and long types. And was wondering if this
> is the correct choice. Also note that whatever it is, it will be cast to
> a 'void *' later.

This won't work on Win64, where C 'long' is 32 bits, but void* is 64 bits.

-n



More information about the NumPy-Discussion mailing list