[Python-Dev] Adding a Rational Type to Python

Michael Hudson mwh21@cam.ac.uk
12 Mar 2001 12:07:19 +0000


Moshe Zadka <moshez@zadka.site.co.il> writes:

> On 12 Mar 2001 08:24:03 +0000, Michael Hudson <mwh21@cam.ac.uk> wrote:
>  
> > If "/" on integers returns a rational (as I presume it will if
> > rationals get in as it's the only sane return type), then can we
> > please have the default way of writing rationals as "p/q"?
> 
> That's proposed in a different PEP. Personally (*shock*) I'd like
> all my PEPs to go in, but we sort of agreed that they will only
> get in if they can get in in seperate pieces.

Fair enough.

> > Having ddd.ddd be a rational bothers me.  *No* langauge does that at
> > present, do they?  Also, writing rational numbers as decimal floats
> > strikes me s a bit loopy.  Is 
> > 
> >   0.33333333
> > 
> > 1/3 or 3333333/10000000?
> 
> The later. But decimal numbers *are* rationals...just the denominator
> is always a power of 10.

Well, floating point numbers are rationals too, only the denominator
is always a power of 2 (or sixteen, if you're really lucky).

I suppose I don't have any rational (groan) objections, but it just
strikes me instinctively as a Bad Idea.

> > Certainly, if it's to go in, I'd like to see
                                                 ^
                                             "more than"
sorry.

> > > > Literals
> > > > 
> > > >     Literals conforming to the RE '\d*.\d*' will be rational numbers.
> > 
> > in the PEP as justification.
>  
> I'm not understanding you. Do you think it needs more justification,
> or that it is justification for something?

I think it needs more justification.

Well, actually I think it should be dropped, but if that's not going
to happen, then it needs more justification.

Cheers,
M.

-- 
  To summarise the summary of the summary:- people are a problem.
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 12