How about adding rational fraction to Python?

Mensanator mensanator at
Mon Feb 25 04:56:15 CET 2008

On Feb 24, 6:09 pm, Mel <mwil... at> wrote:
> Mensanator wrote:
> > On Feb 24, 1:09�pm, Lie <Lie.1... at> wrote:
> >> I decided to keep the num/den limit low (10) because higher values
> >> might obscure the fact that it do have limits. [ ... ]
> > Out of curiosity, of what use is denominator limits?
> > The problems where I've had to use rationals have
> > never afforded me such luxury, so I don't see what
> > your point is.
> In calculations dealing only with selected units of measure: dollars
> and cents, pounds, ounces and tons, teaspoons, gallons, beer bottles
> 28 to a case, then the denominators would settle out pretty quickly.


> In general mathematics, not.

But that doesn't mean they become less manageable than
other unlimited precision usages. Did you see my example
of the polynomial finder using Newton's Forward Differences
Method? The denominator's certainly don't settle out, neither
do they become unmanageable. And that's general mathematics.

> I think that might be the point.

If the point was as SDA suggested, where things like 16/16
are possible, I see that point. As gmpy demonstrates thouigh,
such concerns are moot as that doesn't happen. There's no
reason to suppose a Python native rational type would be
implemented stupidly, is there?

>         Mel.

More information about the Python-list mailing list