[Cython] Question on "numpy_common.pxi" in NumPy tests

Robert Bradshaw robertwb at gmail.com
Thu Mar 29 11:19:46 CEST 2012


On Tue, Mar 27, 2012 at 11:49 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Lisandro Dalcin, 27.03.2012 21:34:
>> On 27 March 2012 17:20, Stefan Behnel wrote:
>>> the NumPy related tests use a file "numpy_common.pxi" that contains this
>>> useless code:
>>>
>>> """
>>> cdef extern from *:
>>>   bint FALSE "0"
>>>   void import_array()
>>>   void import_umath()
>>>
>>> if FALSE:
>>>    import_array()
>>>    import_umath()
>>> """
>>>
>>> Does this serve any purpose? It currently leads to build failures of the
>>> tests in C++ mode because the "import_umath()" call seems to inline code
>>> with a bare "return" statement, which is not allowed in the module init
>>> function (which returns a reference to the module).
>>>
>>> Is there any reason why this can't just die?
>>
>> Oh! long long ago Cython testsuite was able to run without a single C
>> compiler warning... That numpy common file was a hack to silent
>> "defined but not used" warnings about the import array/umath functions
>> defined in  NumPy headers.
>
> Ok - in that case, it should be enough to move the import calls into a cdef
> function body and "avoiding" to call that.
>
> And a comment in the file would be helpful ...

I see you disabled this in the release branch (resulting in the
useless /numpy/core/include/numpy/__multiarray_api.h:1187: warning:
‘int _import_array()’ defined but not used). Was this intentional?

- Robert


More information about the cython-devel mailing list