[Python-Dev] Re: PEP239 (Rational Numbers) Reference Implementation
and new issues
M.-A. Lemburg
mal@lemburg.com
Thu, 03 Oct 2002 17:27:10 +0200
Guido van Rossum wrote:
>>But those feelings are no proof of anything. How do we get the
>>confirmation that using rationals in Python would be easy going and
>>innocuous in practice, beforehand?
>
>
> By adding them to the language but as an isolated type. The right
> conversions should happen when you mix rationals with other types of
> numbers (int/long -> rational -> float -> complex), but no operations
> should return rationals unless a rational goes in.
+1
Note that I started to work on mxNumber to get a feeling for
how well rationals et al. fit the existing world. Turns out
that having separate types is a goog thing. Here's the
coercion scheme I'm using:
mx.Number.Float
^
|
--------> Python float
| ^
| |
| mx.Number.Rational
| ^
| |
Python long --> mx.Number.Integer
^ ^
| |
-------- Python integer
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/