[Cython] NumPy output works on 32bit not on 64bit
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Sun Sep 14 12:17:20 CEST 2008
Dag Sverre Seljebotn wrote:
> Marcin Cieślik wrote:
>> Hello,
>>
>> Does anyone know why this code fails on a 64bit linux machine (it is
>> working on 32 just fine):
>> The compiler complains:
>>
>> bit.c:792: warning: passing argument 3 of '*(PyArray_API + 744u)' from
>> incompatible pointer type
>>
>> and I get a segmentation fault
>>
>> If it is not an issue with Cython could you please direct me
>> somewhere, if have almost no C/C++ skill.
>
> See comments below.
>
>> #####
>> cimport numpy as np
>> ctypedef np.double_t DTYPE_t
>
> This isn't related to the problem, but when you are using the NPY_DOUBLE
> etc. constants directly you should instead do
>
> ctypedef np.npy_double DTYPE_t
>
> This is because there isn't a 1:1 correspondance between the "shorthand"
> types and the NPY_TYPE constants (see bottom of
> Cython/Includes/numpy.pxd for details. BTW, patches for numpy.pxd to add
> the Py_Array_SimpleNew... calls are welcome if submitted).
>
>> from numpy cimport NPY_DOUBLE, NPY_UINT
>> from stdlib cimport malloc, realloc, free
>>
>> cdef extern from "arrayobject.h":
>> cdef object PyArray_SimpleNewFromData(int nd, int *dims,\
>> int typenum, void *data)
>
> dims should be declared with the type npy_intp instead (and this is also
> what your compiler complained about).
Sorry, I meant npy_intp*.
--
Dag Sverre
More information about the Cython-dev
mailing list