Rich Comparisons Gotcha
Mark Wooding
mdw at distorted.org.uk
Mon Jan 5 20:24:58 EST 2009
Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> 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