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

Alex Martelli aleax@aleax.it
Thu, 18 Jul 2002 00:06:45 +0200


On Wednesday 17 July 2002 08:07 pm, Guido van Rossum wrote:
> OK, I'll wait to see if someone submits a working patch.  I still find
> it a non-issue myself.

OK, I'm gonna give it a try -- kludging up Oren's patch so that
the xreadlines object is able to hold a non-addref'd pointer to
the file object (when it's for internal use of the file object) and,
as long as I'm at it, also including the little further kludge that
makes f.readline delegate to f.next if f is holding an xreadlines
object.  Oh, and dropping the xreadlines object on a seek, too.

It's just a few lines' changes to two files after all,
Objects/fileobject.c and Modules/xreadlines.c.  A bit kludgey
and tricky, admittedly, which is perhaps not the nicest thing
in the world given that fileobject.c isn't the shortest, simplest,
or least crucial part of Python.  But anyway, I think I'll have it
ready by early tomorrow my time (it's past midnight and I'm
past the age for all-nighters:-).


Alex