PEP 260: simplify xrange()

Jeff Shannon jeff at
Wed Jun 27 19:54:08 CEST 2001

Dinu Gherman wrote:

> Aahz Maruch wrote:
> >
> > >PS: BTW, why not *add* something useful and make float
> > >    increments work "as expected" in range/xrange...?
> >
> > And how do you expect floating point increments to work?  (Have you paid
> > any attention to the extensive threads on FP over the past few months?)
> No, I haven't followed the discussion... but you asked
> about an implementation; I'm using the one below.

To make a long story short, the discussion regarding FP boils down to the
fact that "1.0" cannot be exactly represented in FP.  Every time you increment

your "frange", you are introducing nasty rounding errors, and by the time
done several thousand iterations, they're going to be very significant
errors.  And the worst part is that there will be *no indication* of where the

wrong answers are coming from unless you happen to monitor your frange
index throughout a debugging run...  and even then it'll only be clear if you
that the FP problem exists.

Jeff Shannon
Credit International

More information about the Python-list mailing list