[Cython] redefining PyIndex_Check

mark florisson markflorisson88 at gmail.com
Sun Nov 11 12:26:19 CET 2012


On 11 November 2012 08:12, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Hi,
>
> instead of overriding an existing definition of "PyIndex_Check" like this:
>
> """
> +#if PY_VERSION_HEX < 0x02050000
> +    /* NumPy headers define PyIndex_Check incorrectly */
> +    #undef PyIndex_Check
> +    #define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) &&
> !PyComplex_Check(o))
> +#endif
> """
>
> which may or may not have come from NumPy, shouldn't we be using our own
> definition of a "__Pyx_PyIndex_Check" in our code instead?
>
> Stefan
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel

I thought about that, but then people do expect PyIndex_Check to work
when they cimport it from cpython. But this fix doesn't really address
that either, it just works if you use memoryviews (it's more of a
quick and dirty hack, this fix needs to be associated with the cimport
of numpy).

Maybe we should use __Pyx_PyIndex_Check internally, and define
PyIndex_Check like we do now for user convenience, and let numpy break
it?

Mark


More information about the cython-devel mailing list