[Cython] [Pyrex] Proposed change to behaviour of "not None"

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Aug 24 02:59:24 CEST 2008


Robert Bradshaw wrote:
> I do 
> see a difference (def functions are exposed to the "outside world") but I 
> think people are just as likely to shoot themselves in the foot with the 
> second option as well. And people will still have to be careful with
> 
> cdef ExtType x = foo()
> x.cdef_attribute

I don't actually care all that much about the Pyrex programmer
shooting himself in the foot -- there are so many ways to do
that in C land that I don't feel like going too far out of
my way to guard against this particular one.

I'm more concerned with him shooting *other* people in the
foot by not properly checking things that come in from
Python land.

This may be another area where Cython philosophy differs
from Pyrex.

As I said before, I wouldn't object to a compiler option
to check for  internal accesses to None, but I wouldn't
accept it as a replacement for None-checking at Python
function boundaries. Since it will have a performance penalty,
people will sometimes want to turn it off once they've got
their code debugged. If it were the only defense against
None, all protection from getting passed None from Python
code would then be lost.

-- 
Greg


More information about the Cython-dev mailing list