[Cython] [Pyrex] Proposed change to behaviour of "not None"
Hoyt Koepke
hoytak at cs.ubc.ca
Sat Aug 23 12:03:55 CEST 2008
Hi,
>> It strikes me that decorators would be a natural way of
>> handling this
>
> I don't think so, because the None/not None distinction is
> a decision that needs to be made individually for each
> parameter -- it's not a property of the function as a
> whole.
True. I was thinking along the lines of changing the default
behavior; which arguably could be (in similar fashion to the
@cython.boundscheck operator). Thus you would either use @notNone
with "or None" to change specified arguments, or no decorator with
"not None" per needed argument.
Given the discussion about functions interfacing to the rest of the
python program, perhaps a good idea is a @checkall or @interface
decorator or something that would say such a function interfaces to
the outside python code and thus the default is to check all the input
arguments for None (and any other issue else that might cause
problems, but I can't think of one at the moment).
>> If part of the
>> reason for switching the default is that writing "not None" for every
>> argument is awkward
>
> No, that's not part of the reason. The reason is that the
> current default easily leads people to write buggy code.
Okay, that makes sense.
--Hoyt
+++++++++++++++++++++++++++++++++++
Hoyt Koepke
UBC Department of Computer Science
http://www.cs.ubc.ca/~hoytak/
hoytak at gmail.com
+++++++++++++++++++++++++++++++++++
More information about the Cython-dev
mailing list