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

Robert Bradshaw <[email protected]> Thu, 21 Aug 2008 01:16:40 -0700
Newsgroups gmane.comp.python.cython.devel,gmane.comp.python.pyrex
Message-ID <[email protected]>
On Aug 20, 2008, at 5:28 PM, Greg Ewing wrote:

> Lisandro Dalcin wrote:
>
>> I know, I can (and I do) use 'Type arg is not
>> None' in argument lists, but I never liked it.
>
> Speaking of that, I've been thinking for a while now
> about making "not None" the default, and requiring
> "or None" to specify that None is an acceptable
> parameter value.
>
> Having seen a number of pieces of Pyrex code that
> were susceptible to being crashed because "not None"
> wasn't used where it should have been, I think
> this would be a safer default. The change may
> break some existing code, though.
>
> What do people think?

I use the fact that extension types can be None all over the place.  
Is this exclusively for arguments? Perhaps that could be OK--at least  
it wouldn't break existing code silently. What would it be called?  
"or None"?

I think a mode that emits tests before every cdef attribute access to  
verify validity could be very useful as well.

- Robert