This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients facundobatista, georg.brandl, mark.dickinson, rhettinger, terry.reedy
Date 2008-10-10.19:57:32
SpamBayes Score 2.410644e-09
Marked as misclassified No
Message-id <1223668654.17.0.0770237228198.issue4087@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2008-10-10 19:57:34terry.reedysetrecipients: + terry.reedy, georg.brandl, rhettinger, facundobatista, mark.dickinson
2008-10-10 19:57:34terry.reedysetmessageid: <1223668654.17.0.0770237228198.issue4087@psf.upfronthosting.co.za>
2008-10-10 19:57:33terry.reedylinkissue4087 messages
2008-10-10 19:57:32terry.reedycreate