A rational proposal
Raymond L. Buvel
levub137 at wi.rr.com
Sat Dec 18 10:44:07 EST 2004
Mike Meyer wrote:
> PEP: XXX
> Title: A rational number module for Python
<snip>
I think it is a good idea to have rationals as part of the standard
distribution but why not base this on the gmpy module
(https://sourceforge.net/projects/gmpy)? That module already provides
good performance. However, it does a few things that may not be good ideas.
1. Floats are converted to rationals. I think your proposal of rational
to float is better.
2. Fails with a TypeError when used with a complex. Again Your proposal
provides a better solution.
3. Fractional powers fail with a ValueError if the root is not exact.
You do not address this in your proposal. Could silently convert to
float in this case but is it better to force the user to be explicit and
use the float() operation?
Ray Buvel
More information about the Python-list
mailing list