On 6 March 2012 16:50, Neal Becker <ndbeck
...@gmail.com> wrote:
> I tried a simple test:
> --
> import numpy as np
> cimport numpy as np
> import cython
> @cython.boundscheck(False)
> @cython.wraparound(False)
> def allequal(np.ndarray[np.float64_t, ndim=1] a):
> cdef:
> np.float64_t a0
> Py_ssize_t i, n=a.size
> a0 = a[0]
> for i in range(n):
> if a[i] != a0:
> return False
> return True
> --
> On compiling I saw:
> /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/__multiarray_ap i.h:
> At global scope:
> /usr/lib64/python2.7/site-
> packages/numpy/core/include/numpy/__multiarray_api.h:1532:1: warning: 'int
> _import_array()' defined but not used [-Wunused-function]
> /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/__ufunc_api.h:2 26:1:
> warning: 'int _import_umath()' defined but not used [-Wunused-function]
> Usually, failing to call import_array() is asking for a segfault. What's going
> on here?
Cython does not use any single bit of the NumPy C API, so there is no
need to call import_array(). Of course, if your code do use the NumPy
C API, you need to make the call yourself.
Perhaps Cython should special-case numpy.pxd and issue the call to
import_array() in the generated C code?
--
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169