On Sat, Sep 29, 2018 at 10:50:24AM +0300, Serhiy Storchaka wrote: > >>How does it differ from float('nan')? > >> > >It is still an integer and would pass through any processing that > >expected an integer as one, (with a value of iNaN). > > Python is dynamically typed language. What is such processing that would > work with iNaN, but doesn't work with float('nan')?
The most obvious difference is that any code which checks for isinstance(x, int) will fail with a float NAN. If you use MyPy for static type checking, passing a float NAN to something annotated to only accept ints will be flagged as an error. Bitwise operators don't work: py> NAN = float("nan") py> NAN & 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for &: 'float' and 'int' Now I'm not sure what Steve expects NANs to do with bitwise operators. But raising TypeError is probably not what we want. A few more operations which aren't supported by floats: NAN.numerator NAN.denominator NAN.from_bytes NAN.bit_length NAN.to_bytes -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/