On Mon, Sep 14, 2020 at 11:05 AM Cade Brown email@example.com wrote:
This would become relevant, if, say Python 4.0 migrated 'inf' and 'nan' to builtin names (like True and False). If that happened, a 'nan' singleton wouldn't make sense unless you had 2**53 of them, so code like:
x is nan
Would be a flawed formulation
Nobody's suggesting that they become keywords representing singletons, which is what True and False are. (At least, I don't think so.) What's being proposed is simply a builtin name that has a value of float("inf"). People don't write "x is 1.5" and they shouldn't use "x is inf". It doesn't matter that there are multiple bit patterns that represent nan; you shouldn't be doing this even when there's only one bit pattern for the value. Yes, sometimes people do this with small integers, and in CPython it may work ("x is 5" will usually be true for any integer 5), but it's just as buggy there and I don't think that's particularly relevant.
(How often do people even use "x is True"?)