Re: How about adding rational fraction to Python?
- From: "mensanator@xxxxxxx" <mensanator@xxxxxxx>
- Date: Sat, 16 Feb 2008 17:49:33 -0800 (PST)
On Feb 16, 6:50�pm, Carl Banks <pavlovevide...@xxxxxxxxx> wrote:
On Feb 16, 5:51 pm, Jeff Schwab <j...@xxxxxxxxxxxxxxxx> wrote:
Carl Banks wrote:
On Feb 16, 3:03 pm, Lie <Lie.1...@xxxxxxxxx> wrote:
Although rationals have its limitations too, it is a much
better choice compared to floats/Decimals for most cases.
Maybe that's true for your use cases, but it's not true for most cases
in general.
Rationals are pretty useless for almost any extended calculations,
since the denominator tends to grow in size till it's practically
unusbale,
What do you mean by "practically unusable?"
So big that a fraction takes 10 minutes to reduce to simplest form and/
or your hard disk starts thrashing.
Out of curiosity, just how big is that?
I ask because I routinely use extremely big
ints and rationals and haven't seen that.
And I'm talking about numbers with, say,
50000 decimal digits up to numbers with
over a billion bits.
It can easily happen with seemingly innocuous calculations.
Where I've had problems is not the size
of the numbers in the repeated calculations
but the number of calculations, say, millions.
I heard similar arguments
made against big integers at one point ("Primitive types are usually big
enough, why risk performance?") but I fell in love with them when I
first saw them in Smalltalk, and I'm glad Python supports them natively.
It's not the same argument, though.
Repeated calculations don't make bignums too large to manage unless
they're growing it exponentially.
My work grows exponentially.
With rationals, the accumulating calculations usually makes the
denominator grow out of control (unless there's some mitigating
factor, like in Paul Rubin's example where there were only a ever few
denominators.)
I don't see any problem there either.
It's entirely possible _I_ won't be able
to use the new Fraction data type. My work
has already left the built-in Python big
ints in the dust in favor of gmpy, so I
have no expectation that the new Fraction
type will be of any use to me.
Carl Banks
.
- References:
- Floating point bug?
- From: robinsiebler
- Re: Floating point bug?
- From: Preston Landers
- Re: Floating point bug?
- From: Diez B. Roggisch
- Re: Floating point bug?
- From: Zentrader
- Re: Floating point bug?
- From: Jeff Schwab
- Re: Floating point bug?
- From: Zentrader
- Re: Floating point bug?
- From: Steven D'Aprano
- Re: Floating point bug?
- From: Jeff Schwab
- Re: Floating point bug?
- From: Steven D'Aprano
- How about adding rational fraction to Python?
- From: Lie
- Re: How about adding rational fraction to Python?
- From: Mark Dickinson
- Re: How about adding rational fraction to Python?
- From: Lie
- Re: How about adding rational fraction to Python?
- From: Carl Banks
- Re: How about adding rational fraction to Python?
- From: Jeff Schwab
- Re: How about adding rational fraction to Python?
- From: Carl Banks
- Floating point bug?
- Prev by Date: Re: Turn off ZeroDivisionError?
- Next by Date: Re: TRAC - Trac, Project Leads, Python, and Mr. Noah Kantrowitz (sanitizer)
- Previous by thread: Re: How about adding rational fraction to Python?
- Next by thread: Re: How about adding rational fraction to Python?
- Index(es):
Relevant Pages
|