[Python-Dev] Rational approximation methods

Leif Walsh adlaiff6 at gmail.com
Sun Jan 20 20:25:29 CET 2008


On 1/20/08, Paul Moore <p.f.moore at gmail.com> wrote:
> Both of these are likely to be of limited use. The most common usage I
> know of is to make a "sensible" rational from a float (i.e., a DWIM
> style conversion 0.1 -> 1/10) or to provide readable output. On the
> other hand, both are subtle to implement, so having a standard
> implementation saves people having to code (and debug) their own.
>
> I suspect that simplest within a particular distance is the form that
> is most often wanted, but I don't have any good evidence for that
> feeling. Putting both in might help people to realise that there *is*
> a choice.
>
> Given that you have implemented them, I'd say leave them in. And I
> like the names trim and approximate, as given in the code you
> referenced.

I can't think of a use case for these either, but the first
(limit_denominator) seems like a generalized round, and I suppose
might be useful for something.

-- 
Cheers,
Leif


More information about the Python-Dev mailing list