[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.

Glenn Linderman v+python at g.nevcal.com
Fri Mar 19 21:05:32 CET 2010

On 3/19/2010 12:50 PM, Mark Dickinson wrote:
> Hah.  This is a very good point, and one I'd somehow missed up until
> now.  I don't think we*can*  reasonably make equality comparisons
> raise NotImplemented (in either 2.x or 3.x), since that messes up
> containment tests:  something like "1.0 in {2, Decimal(3)}" would
> raise a TypeError instead of correctly returning False.  (So the patch
> I've put on the issue tracker is wrong, since it does raise TypeError
> for equality and inequality, as well as for<,>,<= and>=.)

Sounds to me like containment checking is wrong; that if it gets an 
exception during the comparison that it should assume unequal, rather 
than aborting, and continue to the next entry.

Wouldn't the same issue arise for containment tests when disparate, 
incomparable objects are included in the same set?  Why is this different?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100319/486d0dbe/attachment.html>

More information about the Python-Dev mailing list