[Python-ideas] math.inf and math.nan constants

Victor Stinner victor.stinner at gmail.com
Wed Jan 7 15:29:14 CET 2015

2015-01-07 14:33 GMT+01:00 Todd <toddrjen at gmail.com>:
> The current way to get infinite and nan floats are to do float("inf") and
> float("nan"), respectively.  For many applications, this is sufficient.
> However, for scientific and mathematical computing, using inf and nan values
> is very common, and the current approach is very verbose.  So for those
> applications, I think it would be useful if the math standard library module
> provided "math.nan" and "math.inf", which would return the same thing as
> float("nan") and float("inf"), respectively.

Do you expect singletons? I mean that float("nan") is math.nan would be True.

Request of float("0.0") singleton: http://bugs.python.org/issue4024

I dislike the idea of adding math.<float constant>. I agree with Mark
Young, you are already create you own symbols in a module.


More information about the Python-ideas mailing list