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

Devin Jeanpierre jeanpierreda at gmail.com
Wed Jan 7 17:57:50 CET 2015


On Wed, Jan 7, 2015 at 10:25 AM, Chris Barker <chris.barker at noaa.gov> wrote:
> On Wed, Jan 7, 2015 at 8:09 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> - offering a single math.nan is harmful and I strongly oppose it.
>
> defining math.nan as a singleton could be considered harmful, but I don't
> see any harm at all in offering it as a pre-defined constant. We NEED to
> have a way to create a NaN-valued float in any case (and do with
> float('nan')) -- this would be no different.

Maybe this would justify a note in the documentation, that this is one
NaN, but there are many others that are different.

As long as people know not to rely on math.nan being the same object
or having the same bits as every nan, then there's no harm.

-- Devin


More information about the Python-ideas mailing list