[Python-Dev] Single- vs. Multi-pass iterability

Andrew Koenig ark@research.att.com
Wed, 17 Jul 2002 12:53:27 -0400 (EDT)


Gordon> OK, it's a pipe, and one iterator wants to go past
Gordon> what's been received. Is that iterator at EOF? Not
Gordon> really, just "temporary EOF". So should it block?
Gordon> But I'm single threaded and receiving asynchronously.
Gordon> Oh, and it turns out to be a humongous download,
Gordon> and what happens if the buffering mechanism runs
Gordon> out of memory / disk space. Does my process die?

Gordon> Aargh. Too much magic. Too many corner cases.

The implementation of the file should have a choice: Either refuse to
yield a multiple iterator (which seems to be your preference) or yield
one that works (which might or might not be my preference, depending
on circumstances).

In the latter case, I don't think your questions are hard to
answer, because most of the answers fall out of the single-iterator
case.  So if the iterator is at EOF, it should either block or
not, depending on what a single iterator should so.

The only real question is what happens if the buffering mechanism
runs out of space, but that's always a question for such mechanisms;
I don't see why it's any more irksome in this particular context.