Against PEP 240

Remco Gerlich scarblac at pino.selwerd.nl
Wed May 30 13:43:30 EDT 2001


Paul Boddie <paul at boddie.net> wrote in comp.lang.python:
> "Delaney, Timothy" <tdelaney at avaya.com> wrote in message news:<mailman.991184744.16354.python-list at python.org>...
> > 
> > I would much prefer that the default be for exact representation (not FP,
> > not BCD, but exact), and to get something else (perhaps as a speed
> > optimisation) should require additional syntax.
> 
> Yes. Remember the issues that came up when the output of repr was
> changed for Python 2.0 (or was it 2.1?)? 7.35 wasn't 7.35 any more:
> 
> >>> 7.0
> 7.0
> >>> 7.35
> 7.3499999999999996
> 
> How bizarre is that?

But making 7.35 a rational literal by default... that would mean that if you
take a old repr() of a float, then eval() it in the new version, you
suddenly have a rational with value 7.349999999999996. Isn't that what
happens with pickles? And the new repr() of a float will have an 'f' at the
end - more compatibility problems.

I agree that it would be nicer if a literal like 7.35 was a decimal float or
a rational, but I doubt it's worth the backward compatibility issues. But
other people know better than me how big they are.

And I'm afraid that rationals will be *slow*. Try explaining that to
newbies. "Yes, that multiplication is very slow... you can improve it lots
by adding an 'f' to the end of some of the literals."

-- 
Remco Gerlich



More information about the Python-list mailing list