Author mark.dickinson
Recipients facundobatista, jdunck, lorg, mark.dickinson, rhettinger
Date 2009-03-21.20:37:17
SpamBayes Score 2.9976e-15
Marked as misclassified No
Message-id <1237667840.45.0.825973851487.issue2531@psf.upfronthosting.co.za>
In-reply-to
Content
Urk.  That patch produces horrible results when comparing Fractions and 
Decimals:

Python 2.7a0 (unknown, Mar 21 2009, 17:59:48) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fractions import Fraction
>>> from decimal import Decimal
>>> Decimal('2.5') == Fraction(5, 2)
True
>>> Decimal('1.1') == Fraction(11, 10)
False

Either both results should be True (if comparisons between Fractions and 
Decimals work numerically), or both should be False (refuse to
compare Fraction and Decimal).

It looks like what happens is that the Fraction comparison converts the 
second argument to float before comparing. I'm tempted to call this a 
bug in Fraction.__eq__.
History
Date User Action Args
2009-03-21 20:37:20mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, facundobatista, jdunck, lorg
2009-03-21 20:37:20mark.dickinsonsetmessageid: <1237667840.45.0.825973851487.issue2531@psf.upfronthosting.co.za>
2009-03-21 20:37:18mark.dickinsonlinkissue2531 messages
2009-03-21 20:37:17mark.dickinsoncreate