Rationals?
Mike Meyer
mwm at mired.org
Fri Nov 19 11:50:17 EST 2004
Nick Craig-Wood <nick at craig-wood.com> writes:
> Tim Peters <tim.peters at gmail.com> wrote:
>> If you want to use rationals in Python, gmpy is a fine way to do it
>> today.
>
> I would say gmpy (or something like it, eg mxNumber) should be added
> to the standard library.
>
> I'm personally more interested in the fixed point numbers rather than
> the rationals, and having played with various implementations of that
> concept recently, I can say that the new decimal module is by far the
> slowest, and gmpy is by far the fastest.
>
> Eg simplistic program to calculate 1000 decimal places of e :-
>
> gmpy.mpf 0.00271s
> FixedPointNcw.py 0.0118s (FixedPoint.py with simple mod for * by int)
> FixedPoint.py 0.358s
> decimal 1546.9s
>
> People are going to come new to Python and see the decimal type and
> think - oh this looks ideal for high precision calculations, then get
> rather a shock!
Possibly the documentation for the decimal modules (and any rational
module) should mention this, and provide a pointer to gmpy?
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list