Hi, in a (misguided) bugreport (http://bugs.python.org/issue7279) I was questioning the reasons for allowing NaN comparisons with == and != rather than raising InvalidOperation.
I think two main issues emerge from the brief discussion: 1. Should the comparison operators follow the 'compare' function from the standard? The standard says: "An implementation may use this operation [compare] under the covers to implement a closed set of comparison operations (greater than, equal, etc.) if desired. It need not, in this case, expose the compare operation itself." So, I'd say that this supports following 'compare' as closely as possible. In fact the operators <, <=, >, >= already follow 'compare-signal' in their behavior (they raise for any NaN operand). 2. What is the use of == and != outside the decimal scope? Mark mentions that Python uses == to test for set and dict memberships, but that you cannot put decimal NaNs into sets: 'TypeError: Cannot hash a NaN value' I want to add that Decimal('NaN') == Decimal('NaN') gives False, which should somewhat limit the uses of == for NaNs outside the decimal realm anyway. Are there cases where == and != are actually needed to give a result for NaNs? Stefan Krah _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com