[Python-ideas] math.inf and math.nan constants
jeanpierreda at gmail.com
Wed Jan 7 15:55:57 CET 2015
On Wed, Jan 7, 2015 at 8:29 AM, 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.
That seems like a bad idea. There are millions of different NaNs, so
xxx is math.nan would only work sometimes. (math.isnan is the way to
deal with this.)
More information about the Python-ideas