[Python-ideas] Suggestion: Extend integers to include iNaN

Kyle Lahnakoski klahnakoski at mozilla.com
Mon Oct 1 08:10:26 EDT 2018

On 2018-09-30 10:45, Anders Hovmöller wrote:
>>> I am roughing out such a class and some test cases which will hopefully 
>>> include some cases where the hoped for advantages can be realised.
>>> My thinking on bitwise operations is to do the same as arithmetic 
>>> operations, i.e. (anything op iNaN) = iNaN and likewise for shift 
>>> operations.
>> Steve,
>> While you are extending a number system, can every int be truthy, while
>> only iNan be falsey?  I found that behaviour more useful because
>> checking if there is a value is more common than checking if it is a
>> zero value.
> I’m not saying you’re wrong in principle but such a change to Python seems extremely disruptive. And if we’re talking about robustness of code then truthiness would be better like in Java (!) imo, where only true is true and false is false and everything else is an error. If we’re actually talking about changing the truth table of Python for basic types then this is the logical next step.
> But making any change to the basic types truth table is a big -1 from me. This seems like a Python 2-3 transition to me. 

Sorry, I can see I was unclear:  I was only asking that the new number
system (and the class that implements it) have truthy defined differently. 

My imagination never considered extending ints with iNaN. I would
imagine the iNaN checks on every int operation to be noticeably slower,
so out of the question.

More information about the Python-ideas mailing list