Terry J. Reedy <[EMAIL PROTECTED]> added the comment: More sensibility offenders:
>>> s = {fractions.Fraction(17,1), decimal.Decimal(17)} >>> s-{17} set() Removing one thing removes two. >>> s.remove(17) >>> 17 in s True Removing something leaves it there. >>> s {Fraction(17, 1)} # random choice Removing one thing and subtracting the set with that one thing give different results. >>> s = {decimal.Decimal(17), fractions.Fraction(17,1)} >>> s.remove(17) >>> s {Decimal('17')} The behavior of 'set' s depends on the order items are added. > Facundo's suggested code: if isinstance(other, float) and int(other)==other: other = int(other) would be more efficient, I assume as if isinstance(other,float): ifloat = int(other) if other == ifloat: other = ifloat or if the CAPI has an efficient 'float_isint' function that accesses the bits of a float, as the C equivalent of if isinstance(other, float) and float_isint(other): other = int(other) I remember float-Decimal comparison being rejected/deferred in part for being problematical for fractional values. That is why I suggested implementing it, at least for the present, for integral floats (and Fractions) only, which are relatively easy to detect. _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4087> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com