[Python-ideas] math.inf and math.nan constants
Antoine Pitrou
solipsis at pitrou.net
Wed Jan 7 16:02:02 CET 2015
On Wed, 7 Jan 2015 15:29:14 +0100
Victor Stinner <victor.stinner at gmail.com>
wrote:
> 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>.
You mean like math.pi and math.e? :)
More information about the Python-ideas
mailing list