Pre-PEP: reverse iteration methods

Lulu of the Lotus-Eaters mertz at gnosis.cx
Thu Sep 25 03:02:11 EDT 2003


|> Humans cannot solve the halting problem either, FWIW.  Just because a
|> programmer THINKS an iterator is finite, it don't mean it is!

David Eppstein <eppstein at ics.uci.edu> wrote previously:
|Well, true, but if you are a programmer and don't know whether your
|program is always going to halt, you probably shouldn't have written it
|that way.

Sure, I generally agree.  But creating a special __finite__ attribute
(or whatever) introduces a new source of potentially rather bad errors.
Doing a reverse iteration on an iterator that turns out to be infinite
(or even just VERY big) will presumably either freeze the system or
cause a memory overrun.

Moreover, I can see a class of cases where it's not obvious about
halting.  A generator that depends on some runtime data might halt for
all the "normal" cases, but wind up running infinitely long for special
(untested) cases.  Some attractors, for example, with the right
parameters (or wrong, depending on how you think of it) are strange, if
you know what I mean :-).

Yours, Lulu...

--
mertz@  | The specter of free information is haunting the `Net!  All the
gnosis  | powers of IP- and crypto-tyranny have entered into an unholy
.cx     | alliance...ideas have nothing to lose but their chains.  Unite
        | against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------






More information about the Python-list mailing list