Guido van Rossum added the comment: All in all, Decimal is the odd man out -- it may never become a full member of the Real ABC. The built-in types complex, float and int (and long in 2.x) all support mixed-mode arithmetic, and this is one of the assumptions of the numeric tower -- and of course of mathematics. The new Rational type can be designed to fit in this system pretty easily, because it has no pre-existing constraints; but the Decimal type defies coercion, and is perhaps best left alone. It's already breaking the commonly understood properties of equality, e.g. 1.0 == 1 == Decimal("1") != 1.0.
--Guido On Jan 9, 2008 7:51 PM, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > Mark Dickinson added the comment: > > Allowing automatic coercion to and from Decimal sounds dangerous and > complicated to me. Mightn't it be safer just to disallow this (at least for > now)? > > I think something like trim() (find the closest rational approximation with > denominator bounded by a given integer) would be useful to have as a Rational > method, but probably only for explicit use. > > I'm still worried about equality tests: is it possible to give a good reason > why Decimal("2.5") == Rational(5, 2) should return False, while Rational(5, 2) > == 2.5 returns True. Can someone articulate some workable principle that > dictates when an int/float/complex/Rational/Decimal instance compares equal to > some other int/float/complex/Rational/Decimal instance of possibly different > type but the same numerical value? > > > __________________________________ > Tracker <[EMAIL PROTECTED]> > <http://bugs.python.org/issue1682> > __________________________________ > __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1682> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com