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

Robert Bradshaw robertwb at gmail.com
Tue Mar 27 22:13:11 CEST 2012

On Tue, Mar 27, 2012 at 7:20 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Hi,
> 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?

IIRC, this was to avoid warnings about unused functions when importing
the numpy headers without manually invoking these functions.

Perhaps taking their address rather than "calling" them would be
better (though this may involve creating yet more unused

- Robert

More information about the cython-devel mailing list