Against PEP 240

Roman Suzi rnd at onego.ru
Thu May 31 09:36:16 EDT 2001


On Thu, 31 May 2001, Don O'Donnell wrote:

> Robin Becker wrote:
> > 
> > I am strongly opposed to the intent of PEP 240. I would prefer the
> > literal floats to remain. Let those that want infinite precision pay the
> > price by adding an 'R' to their literals. This PEP seems purely biassed
> > towards the needs of naive programmers and I feel that is wrong; this
> > whole industry has grown up with the old style (and coped quite well).
> > If naive users are to be the only designers we'll end up badly.
> > --
> > Robin Becker
> 
> I agree with PEP 239 that Python should have a rational number type, 
> but I'd like to consider the part of PEP 240, which proposes that the
> literal representation for a rational should conform to the regexp: 
> r"\d+\.\d*".
> 
> This representation seems to imply that all rationals must have a 
> denominator which is a power of 10.  I.E., 7.35 => 735/100
> How would one write the literal for (and what would be the result 
> of repr() for) the rational number 353/197 for example, using the 
> literal notation  d.ddddd...?  No, this representation is too limiting
> for expressing the general case of rational numbers.  We need a more 
> general format which allows both the numerator and denominator to be
> specified.  
> 
> Since there is talk of, and a PEP 238 advocating, changing the meaning 
> of the integer divide operator "/" anyway, let's make _it_ the symbol 
> for expressing rationals:
> 
> >>>a = 353/197     # a is a rational number

I recall my calculator has special char for rational type.
It looks like L turned 90 degrees clock-wise. 
(let me denote it by "\")

The calculator can switch between 3 or 4 modes of 
number representations.

2+1\3

I think this type is a good idea for Python. But how to mix types 
with existing floats and other types?

Probably, there could be new operation entered (like \) 
to specify that we want rational type?

for example, 

123\1 will mean rational 123
while 123\23 will be canonically (in proper form): 5+8\23

There will be no rational literals involved.

Usual coerce rules apply. 

It must be somewhere at the level below complex,
because it's a new "complex" type. 
What if there will be other "basic" types?
(Complex types can't use integers or longs for it's parts)

Once more, "\" is used for convenience.

Lets make AP(ython)L(anguage) ;-)

ly yours, Roman A.Suzi

-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list