In PEP 754's rejection notice, it's stated that:
This PEP has been rejected. After sitting open for four years, it has failed to generate sufficient community interest.
Several ideas of this PEP were implemented for Python 2.6. float('inf') and repr(float('inf')) are now guaranteed to work on every supported platform with IEEE 754 semantics. However the eval(repr(float('inf'))) roundtrip is still not supported unless you define inf and nan yourself:
>>> inf = float('inf') >>> inf, 1E400 (inf, inf) >>> neginf = float('-inf') >>> neginf, -1E400 (-inf, -inf) >>> nan = float('nan') >>> nan, inf * 0. (nan, nan)
This would seem to say there is no native support for Inf, NaN and -Inf in Python, and the example provided is accurate! But, it is needlessly verbose:
$ python2.7
>>> 1e400
inf
>>> 1e400 * 0
nan
>>> -1e400 * 0
nan
>>> -1e400
-inf
$ python3
>>> 1e400
inf
>>> 1e400 * 0
nan
>>> -1e400 * 0
nan
>>> -1e400
-inf
These are canonical representations of the number 1 * 10 ^ 400. The names inf
and nan
do not exist in the grammar by default, but if they are there in the representation then why aren't inf
and nan
keywords?
I am not asking why the PEP was rejected as that is opinion-based.
My guess is that no one wanted to clutter the namespace needlessly.
If you want to do math, you can still do:
import math
print(math.inf)
print(-math.inf)
print(math.nan)
Output:
inf
-inf
nan