Against PEP 240

Tim Peters tim.one at home.com
Thu May 31 07:17:31 CEST 2001


[Alex Martelli]
> ...
> I wish all Pythonistas had a modicum of experience teaching Python
> to newbies that are skeptical enough of techies to NOT be sold a bill
> of goods.  Just TRY to explain:
>
> D:\py21>python
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> Alternative ReadLine 1.1 -- Copyright 2001, Chris Gonnerman

Heh!  I'm baffled already:  where did "1.1" come from?

>>> 1.1
1.1000000000000001
>>>

Maybe I'm *too* used to this stuff <wink>.

> >>> 7.35
> 7.3499999999999996
> >>>
>
> to three such people to which you have been promoting Python as a
> language easy to use AND UNDERSTAND.  Now they find out that, to
> deal with such an elementary concept as "7 dollars and 35 cents",
> they first have to get a major in advanced computer science, else
> BY DEFAULT 7.35 does not MEAN 7.35, it means 7.34999 etc.

You can in large part blame me for the display.  I've been fighting tooth
and nail not to go back to *displaying* 7.345 in this case (and, of course,
cases like it).  We get oodles of complaints about it, of course, but now
they're always about the same thing:  why is the display "wrong"?  Before,
newbies didn't pick up on this at first, and so the complaints came later
and in a dozen different forms, as they eventually got surprised by the
various *consequences* of that 7.35 wan't what it appeared to be.  Then it
was even harder to explain that, on top of whatever specific surprise they
were facing, the interpreter loop was-- in a real sense --lying to them too,
but "for their convenience" (ya, right).

So on this issue I take the heat, agreeing with Kahan that artificially
pretty display is "a pious fraud" that just leads to worse problems.  So
long as we're using HW binary fp, better to face the truths of it from the
start.

Until something better can be done, Guido pressed me to play corporate
apologist and write a new Appendix for the Tutorial.  The first draft is
attached (in plain text) to this patch:

<http://sf.net/tracker/index.php?func=detail&aid=426208&group_id=5470&atid=3
05470>

People who hate binary fp a lot may be disappointed at the lack of strident
condemnation <wink>.  Other comments can be attached to the patch.





More information about the Python-list mailing list