Rich Comparisons Gotcha

Mark Wooding mdw at
Tue Jan 6 02:24:58 CET 2009

Steven D'Aprano <steven at> wrote:

> I've already mentioned NaNs. Sentinel values also sometimes need to
> compare not equal with themselves. Forcing them to compare equal will
> cause breakage.

There's a conflict between such domain-specific considerations (NaNs,
strange sentinels, SAGE's equations), and relatively natural assumptions
about an == operator, such as it being an equivalence relation.

I don't know how to resolve this conflict without introducing a new
function which is (or at least strongly encourages developers to arrange
for it to be) an equivalence relation.

-- [mdw]

More information about the Python-list mailing list