[Numpy-discussion] checking for array type in C extension

Pauli Virtanen pav@iki...
Fri Jun 18 10:06:36 CDT 2010

pe, 2010-06-18 kello 16:43 +0200, Berthold Hoellmann kirjoitti:
> The documentation (i refere to NumPy User Guide, Release 1.5.0.dev8106)
> claims that numpy.int is platform int and that "NPY_INT" is a C based
> name, thus referring to int also. So if I want to use "int" platform
> independent in my extension module, what do I do to check whether the
> correct data is provided. I want to avoid one of the casting routines,
> such as "PyArray_FROM_OTF" or "PyArray_FromAny"? Do I have to use
> "PyArray_ITEMSIZE"? But "PyArray_ITEMSIZE" indicates that "numpy.int"
> are not platform integers. It returns "8" on Linux64, where
> "sizeof(int)==4".
> So is this a bug in 1.4.1, in the 1.5 beta documentation or a
> misunderstanding on my side?

I guess the documentation needs clarification, as numpy.int is not
actually the platform-size integer, but the Python-size integer.

The platform-size integer corresponding to C "int" is IIRC numpy.intc,
which should result to the same sizes as NPY_INT.

Pauli Virtanen

More information about the NumPy-Discussion mailing list