warning: 'int _import_array()' defined but not used

959 views
Skip to first unread message

Neal Becker

unread,
Mar 6, 2012, 8:50:39 AM3/6/12
to cython...@googlegroups.com
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_api.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:226: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?

Lisandro Dalcin

unread,
Mar 6, 2012, 9:27:17 AM3/6/12
to cython...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages