[Python-Dev] Decimal <-> float comparisons in py3k.

Guido van Rossum guido at python.org
Wed Mar 17 02:05:29 CET 2010


On Tue, Mar 16, 2010 at 5:36 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
>
>
>
> On Mar 16, 2010, at 9:41 AM, Guido van Rossum wrote:
>
>> I'd say if you're not going to forward-port this to Python 3, it
>> shouldn't go into Python 2 -- in that case it would make more sense to
>> me to back-port the exception-raising behavior.
>
> Python 3 doesn't need it because it is possible to not give a result
> at all.  Python 2 does need it because we have to give *some*
> result.
>
>>
>> Also supporting comparisons but not other mixed operations is going to
>> be confusing. If you are sticking to that behavior I think mixed
>> comparisons should also be ruled out.
>
> The difference is that mixed comparisons currently do give a result,
> but one that is non-sensical.  The proposal is a make in give a
> meaningful result, not as an extra feature, but in an effort to not
> be wrong.
>
> Since 2.x has to give a result, we should make it useful.
> Since 3.x does not make the comparison, it is okay to punt.

No. You are talking like there is no path from 2.7 to 3.x. Since the
result in 2.x was never useful, you should not add a dead-end feature.
And there is no reason (other than backwards compatibility) why the
comparison couldn't raise an exception in 2.x as well -- e.g.
str<->unicode comparisons do this already. (It used to be required
that comparisons had to always return a result, but that was done away
with long before Decimal was introduced.)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list