(Please excuse my English)

Fredrik Lundh wrote:

> is this
>
>     >>> 1.0 > "0"
>     False
>
> also a bug ?

It may be tolerable for unrelated types like int and list, but it's a
gross usability issue
when it comes to mixing floats and decimals. I believe the latter are
going to be mixed
and compared a lot (mostly accidentally). Current decimal/float
comparison
will be a rich source of obscure bugs.

Consider expression "n > 0.1", where n is some "number".
This expression works as expected while type(n) in (int, long, float).
But when you add Decimal to the list of numeric types, it becomes a
bug.
Worse, a hidden bug.

Now, if decimal/float comparison raised a TypeError, like (decimal +
float) does,
the bug would surface much earlier.
Another option is to coerce decimal and float to the same type,
possibly with
loss of precision. It could be controlled via decimal context.

(This has probably been discussed to death. If so, just point me in the
right direction.)

- kv

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to