Future division patch available (PEP 238)

Stephen Horne steve at lurking.demon.co.uk
Fri Jul 27 04:55:51 EDT 2001


On Wed, 25 Jul 2001 16:31:38 GMT, Paul Winkler
<paul at calendargalaxy.com> wrote:

>> - Just a wild idea: the problem you want to solve is that the existing
>>   division operator mixes two totally different meanings and thus
>>   leads to nasty surprises.
>> 
>>   What if `/` applied to two integer values returned neither an
>>   integer nor a float but an object carrying the float result but
>>   behaving like an integer if used in an integer context?

I suspect this would move problems around (at considerable cost in
terms of Pythons complexity and reliability) rather than solving them.
For instance, what type would 5 + (1/2) have - float, integer or the
hybrid?

>thought the whole point of the PEP was to make division behave consistently -
>that is, always return the same type of result regardless of the operands.

No - that would require many more division operators. Consider complex
division, division with classes (such as matrix division) etc.

However, this is arguably not really the point.

Both float and complex try to represent continuous measures (there's
not much use for discrete complex measures - even a Z transform is a
continuous complex measure, even though it is intended for use with
discrete signals).

Also, no doubt part of the issue is that integer-avoiding division
would equally seek to convert integers to floats within matrices or
other structures before doing division.




More information about the Python-list mailing list