Rich Comparisons Gotcha
steven at REMOVE.THIS.cybersource.com.au
Tue Dec 9 03:45:17 CET 2008
On Sun, 07 Dec 2008 16:24:58 -0800, George Sakkis wrote:
> On Dec 7, 6:37 pm, Steven D'Aprano <st... at REMOVE-THIS-
> cybersource.com.au> wrote:
>> x = log(-5) # a NaN
>> y = log(-2) # the same NaN
>> x == y # Some people want this to be true for NaNs.
>> # Compare x and y directly.
>> log(-5) == log(-2)
>> # If x == y then exp(x) == exp(y) for all x, y. exp(log(-5)) ==
>> -5 == -2
>> and now the entire foundations of mathematics collapses into a steaming
>> pile of rubble.
> And why doesn't this happen with the current behavior if x = y = log
> (-5) ? According to the same proof, -5 != -5.
You're right, I was a little sloppy in my "proof". There are additional
subtleties going on.
More information about the Python-list