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

Brett Cannon brett at python.org
Sat Jan 10 21:56:21 CET 2015


On Wed Jan 07 2015 at 5:20:04 PM Guido van Rossum <guido at python.org> wrote:

> On Wed, Jan 7, 2015 at 2:13 PM, Chris Angelico <rosuav at gmail.com> wrote:
>
>> On Thu, Jan 8, 2015 at 6:02 AM, Bruce Leban <bruce at leban.us> wrote:
>> > There is a problem here but that's not it. The problem is that
>> >
>> > float("nan") is float("nan") => False
>> > math.nan is math.nan => True
>> >
>> >
>> > So is this an attractive nuisance that will make people think they can
>> > should use x is math.nan instead of math.isnan(x)? Hopefully not but
>> > something to consider. Pylint should flag this usage.
>>
>> I don't think that's a problem. Using 'is' to test floating-point
>> values is already broken:
>
> [...]
>>
>
> Correct. And the first half of the thread was comparing the convenience of
> defining a nan constant at the top of your module using "nan =
> float('nan')" with "from math import nan". That would have the exact same
> 'is' problem.
>
> There is no attractive nuisance here except that this thread itself is
> wasting everybody's time. :-
> )
>

Exactly. Someone should file a bug to track this and then nosy mark.dickinson,
rhettinger, stutzbach as specified in the experts index. Then the work can
be tracked and be seen done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150110/37c9e1d9/attachment-0001.html>


More information about the Python-ideas mailing list