[Cython] Fwd: Re: [cython-users] checking for "None" in nogil function

Robert Bradshaw robertwb at gmail.com
Tue May 8 02:19:58 CEST 2012


On Mon, May 7, 2012 at 5:05 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Stefan Behnel wrote:
>
>> The main reason we didn't change this behaviour back then was that it
>> would
>> clearly break user code and we thought we could do without that. That's
>> different from considering it "right" and "good".
>
> I changed the None-checking behaviour in Pyrex because I *wanted*
> to break user code. Or rather, I didn't think it would be a
> bad thing to make people revisit their code and think properly
> about whether they really wanted to allow None in each case.

That's great if you have the time, but revisiting half a million lines
of code (e.g. Sage) can be quite expensive... especially as a
short-term patch for a better long-term solution (mostly optimized
away None-checks on access).

By bigger issue of why I don't think this is the right long-term
solution is that

(cp)def foo(ExnClass arg):
    ...

should behave the same as

(cp)def foo(arg):
    cdef ExnClass a = arg

I think part of the difference is also how strongly the line is drawn
between the compiled and un-compiled portions of the program. Cython
blurs the line (more) between "called from Cython" and "called from
Python," and only the latter doing None-checking is inconsistent too.

- Robert


More information about the cython-devel mailing list