PEP239 (Rational Numbers) Reference Implementation and new issues

Christian Tismer tismer at tismer.com
Wed Oct 9 21:44:31 EDT 2002


Chris Gonnerman wrote:

[snipped good stuff again, including stuff snipped]

>>Naa, this is slightly different.
>>I don't think al too many people asked for an integer
>>in the first place when they wrote
>>
>>   1/3
> 
> 
> Ahhh...
> 
> you are thinking, "1/3 as a literal" and I am seeing it as
> an EXPRESSION.  So to you, this:
> 
>     1/3
> 
> is not the same as this:
> 
>     n = 1
>     m = 3
> 
>     n/m
> 
> Or have I misunderstood?  Because if you give me a rational
> for the second option I'll be royally ticked off.  For the
> first option, giving me a rational serves me right.

No, sorry, I didn't distinguish literal form expression.
The 1/3r thingie appeared on python-dev, and I perceived
it as a modifier for the whole expression.
Probably wrong, and you are right with 3r = rational(3,1)
There had been proposals like 1:3, [1:3] and so on,
and I was thinking of syntactic sugar for the whole
expression.
...bigger snip...

>>Now, returning a true fraction instead sounds exciting.
>>Having fractions in the language is exciting as well,
>>after I had them in Mathematica for long years.
> 
> 
> ... let's not get too excited here ...
> 
> 
>>Finally, if I had to choose, I would either stick with
>>the old truncation, or use rationals.
>>Rationals would be welcome, even if there were just
>>an extension module.
> 
> 
> Now that idea I can get behind.  I'd never use them, but
> (IMHO) you can never have too many tools in the box.
> 
> What I was proposing wasn't actually
> 
>     1/3R
> 
> as a rational literal; THIS is a rational literal:
> 
>     3R

Now it is clear.

> and since math operations involving a rational and an int
> or float would "promote" the int or float to rational, this:
> 
>     1/3R
> 
> would return a rational one-third value.
> 
> In other words, the R suffix would make a literal integer
> "n" into a rational of the form "n/1".

That's good anyway, and not related to a decision what 1/3
should be. Let's see what comes...

ciao - chris[2]

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/






More information about the Python-list mailing list