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

Chris Angelico rosuav at gmail.com
Tue Jan 13 03:29:20 CET 2015

On Tue, Jan 13, 2015 at 1:12 PM, Guido van Rossum <guido at python.org> wrote:
> But what other methods from Decimal would we have to add to float (and to
> int, etc.)?
> IIRC there are just too many differences between Decimal and float to ever
> hope for equivalence. (How do you spell sin() of a Decimal?)

These kinds of features should be modular (in the Mark Rosewater sense
of the word). Adding float.is_nan is useful whether or not you can
calculate the sine of a Decimal (and vice versa). It's currently
possible to ask the question "Are you NaN?" of both floats and
Decimals, and this simply adds compatible spellings for it.

I'm +0 on it, but only because I don't use Decimal NaN in my code. If
I did, I'd probably be a strong +1.


More information about the Python-ideas mailing list