PEP 240 scares me

Pearu Peterson pearu at cens.ioc.ee
Thu Mar 22 16:44:31 EST 2001


Hi!

I very much agree what is in PEP 240 Rationale, but its Proposal scares me
a lot, its like a nightmare (and I actually don't see any logical
connection between the Rationale and the Proposal).
Let me explain why.

It is true that 1/2 == 0 surprise new (Python) programmers (but I quickly
learned to write 1./2 or 1/2. or 1/float(n) etc). 
But making 1.2 to be a rational
                                1
                               ---
                                2
will most definitely surprise new (Python) programmers even more *because*
in ever programming language I know of (C, Fortran, Maple, Mathematica, Matlab
to name few), use 1.2 to denote a float that is equal to
                                6
                               ---
                                5
(up to a computers ability to represent such a number in float).

I apologize if my message is too emotional but after reading the PEP 240
Proposal, I felt very uncomfortable.
 
I think that any of the following representation of rational numbers are
much more appropriate, though none of them is perfect:
         1//2
         1r/2         (like 1j+2 is a complex number)
         1/2r         (like 1+2j)
         1_2
         1:2          (that's probably tricky in Python)

Note that they all raise SyntaxError in current Python, so, just pick one
and there will be no backwards compatibility problems. Using 1.2 for a 
`half' will probably break any Python code that does
(scientific) numerical calculations.

In conclusion, I will look forward for Python to support rational
numbers. Though floats are always imperfect in computers representation,
somebody in c.l.py even said hating floats. I don't love them either but
I *do* need them. Let's not make things worse than they already are.

Regards,
	Pearu





More information about the Python-list mailing list