[Python-Dev] cmp(x,x) (original) (raw)

Jewett, Jim J jim.jewett at eds.com
Tue May 25 12:30:38 EDT 2004


Gustavo Niemeyer: <niemeyer at conectiva.com>

Looking again, this is true for any operation, not only PyEQ or PyNE.

CVS has previously restricted the shortcut to those two, but I agree it should be all or nothing.

Even unordered objects normally compare equal to themselves; if "is" does not imply "eq", then we are by definition dealing with an exceptional case. (NaN, or SQL NULL, or DUMMY, or ...) Since different exceptional cases will have different rules, it might be reasonable to ask the creator to use a custom comparison function. They will often have to do this anyway.

Instead of if (a == b):

they can write if (a is not NULL) and (a == b): or if (a == b) and (not isNaN(a)):

-jJ



More information about the Python-Dev mailing list