Rational Numbers
Nick Maclaren
nmm1 at cus.cam.ac.uk
Fri Jan 12 10:05:23 EST 2007
In article <mailman.2643.1168611301.32031.python-list at python.org>,
Carsten Haese <carsten at uniqsys.com> writes:
|> On Thu, 2007-01-11 at 23:47 +0000, Nick Maclaren wrote:
|> > In article <mailman.2597.1168550439.32031.python-list at python.org>,
|> > Facundo Batista <facundo at taniquetil.com.ar> writes:
|> > |> Noud Aldenhoven wrote:
|> > |>
|> > |> > When I was programming in a mathematical project I began to wonder if python
|> > |> > supports rational numbers[1]. In a language like magma[2] it's not such a
|> > |> > problem. Does python supports something simular?
|> > |>
|> > |> Python does not have rational numbers.
|> > |>
|> > |> There's a (rejected) PEP about this, PEP-239:
|> > |>
|> > |> http://www.python.org/dev/peps/pep-0239/
|> > |>
|> > |> Maybe you also want to read the section "Why not rational?" of
|> > |> PEP-327...
|> > |>
|> > |> http://www.python.org/dev/peps/pep-0327/#why-not-rational
|> >
|> > Oh, God. Decimal delusions again :-(
|> >
|> > There are good arguments for not having a rational type, but the idea
|> > that decimal floating-point is in any way a replacement is cuckoo.
|>
|> You're putting words in Facundo's mouth. Facundo didn't say why we
|> should read that section of PEP 327. I think he merely pointed to the
|> slow performance of rational numbers that's explained in that section.
|> (Facundo is the author of PEP 327, so I find it unlikely that he has
|> delusions about what decimals can and can't do.)
You're putting words in MY mouth! I didn't say that he did. But I
agree that my words could easily be read that way, so I apologise for
any misunderstanding.
|> It is true that decimal arithmetic is not a replacement for rational
|> arithmetic, but I don't see anybody on this thread or in PEP 327 stating
|> that it is.
Read them again, more carefully :-(
The BDFL Pronouncement rejecting PEP 239 does, even if it does qualify
it by saying "to some extent". And it was that PEP that I was primarily
referring to in that remark.
The "Why not rational?" section of PEP 327 quotes Alex Martelli as saying
that Rational are not worth doing without Decimal, which makes no sense
at all. All it does is to plug Decimal for a purpose for which it is
completely unsuited; not all rational numbers have denumerators that are
powers of 10.
Regards,
Nick Maclaren.
More information about the Python-list
mailing list