[Python-Dev] Comparing heterogeneous types

Chermside, Michael mchermside at ingdirect.com
Wed Jun 23 08:37:31 EDT 2004

> If "a <= b" is to mean we convert a and b to either float or 
> long depending on
> their magnitude, would it make any sense at all if other 
> operators like "a +
> b" would do the same, to maximize precision?

IMHO, probably not. We are NOT suggesting that "a <= b" mean
we convert a and b to float or long depending on magnitude,
we are suggesting that is just means to compare the values...
and that if one value is float than it should be interpreted
as if it had the precise value it represents rather than
some range of values. Sure, we talked about converting things,
but that was an *implementation* detail.

I suspect that the reason Guido prefers "a + b" to always
return a float when one is a float and the other is a long
is because of his (recently noted in another thread)
preference for operations to be consistent in what type
they return. Of course, it COULD be done more accurately using
your approach. The only good reason I can come up with for
NOT doing so is to have the rule for what type results from
arithmatic operations on mixed types be a simple one.

-- Michael Chermside

This email may contain confidential or privileged information. If you believe you have received the message in error, please notify the sender and delete the message without copying or disclosing it.

More information about the Python-Dev mailing list