[Python-Dev] Comparing heterogeneous types

Guido van Rossum guido at python.org
Wed Jun 23 10:57:14 EDT 2004


> Well, just for quick consideration (and probably rejection :-) :
> 
> 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?
> 
> >>> 1L + 0.5
> 1.5
> >>> L = 100000000000000000000000L
> >>> float(L)
> 9.9999999999999992e+22
> >>> float(L+1)
> 9.9999999999999992e+22
> >>> L + 1.0
> 9.9999999999999992e+22      # currently
> 100000000000000000000001L   # suggested

No, the return type shouldn't depend on the input values.  (This isn't
an issue for comparisons, since those always return a bool.)

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list