[Python-Dev] Why is nan != nan?
dickinsm at gmail.com
Thu Mar 25 00:31:57 CET 2010
On Wed, Mar 24, 2010 at 11:11 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Wed, Mar 24, 2010 at 7:02 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
>> So if I understand correctly, you propose that float('nan') ==
>> float('nan') return True. Would you also suggest extending this
>> behaviour to Decimal nans?
Okay. So now it seems to me that there are many decisions to make:
should any Decimal nan compare equal to any other? What if the two
nans have different payloads or signs? How about comparing a
signaling nan with either an arbitrary quiet nan, or with the exact
quiet nan that corresponds to the signaling nan? How do decimal nans
compare with float nans? Should Decimal.compare(Decimal('nan'),
Decimal('nan')) return 0 rather than nan? If not, how do you justify
the difference between == and compare? If so, how do you justify the
deviation from the standard on which the decimal modulo is based?
In answering all these questions, you effectively end up developing
your own standard, and hoping that all the answers you chose are
sensible, consistent, and useful.
Alternatively, we could do what we're currently doing: make use of
*existing* standards to answer these questions, and rely on the
expertise of the many who've thought about this in depth.
You say that you don't see any compromise: I say that there's value
in adhering to (de facto and de jure) standards, and I see a
compromise between standards adherence and Python pragmatics.
More information about the Python-Dev