[Python-Dev] Coercion and comparison of numbers
Guido van Rossum
guido@digicool.com
Tue, 01 May 2001 20:29:28 -0500
> I just received a bug report for mx.Number which revealed a
> probelm with the comparison code in Python 2.1. Looking at
> the code it seems that one of my original coercion patches
> did not make it into the core. I added a new API PyNumber_Compare()
> knows about the new coercion mechanism and should be called for
> numbers instead of trying coercion in PyObject_Compare().
>
> Was this part of the coercion patch left out on purpose or
> a simple oversight ? I hope the latter...
Hard to say. I don't think I paid very close attention to your patch;
Neil did, but I changed a lot of the code around coercions and
comparisons in order to implement rich comparisons. So, several
things may have happened: Neil lost it; Neil decided against it; or I
ripped it out.
Can you elucidate me regarding the issues? (If there's code, please
quote it or link to a specific patch.) Since the concept of "number"
is ill-defined at best, when exactly should PyNumber_Compare() be
called? What is it supposed to do? Does it need a rich cousin?
--Guido van Rossum (home page: http://www.python.org/~guido/)