Patches item #1677872, was opened at 2007-03-10 13:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1677872&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mark Russell (mark_t_russell)
Assigned to: Nobody/Anonymous (nobody)
Summary: Efficient reverse line iterator 

Initial Comment:
This is an implementation of __reversed__ for the TextIOWrapper type from the 
new IO interface (see http://docs.google.com/Doc?id=dfksfvqd_1cn5g5m).  It is 
used as:

    import io
    for line in reversed(io.open(filename)):
          ...

It is efficient (only reads a block at a time) but can handle arbitrary length 
lines.  It is useful for scanning backwards through big log files, but my main 
reason for submitting it is as a demonstration of the usefulness of the new IO 
layers - it works by putting a new buffering layer round the RawIOBase object 
from the open() call.

It's just a proof of concept, but if there's interest in this I'm happy to 
write unit tests and documentation.

The patch also makes io.BufferedReader support buffering, and adds a very 
minimal implementation of io.TextIOBase and io.TextIOWrapper (needed to make 
io.open() work).



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1677872&group_id=5470
_______________________________________________
Patches mailing list
Patches@python.org
http://mail.python.org/mailman/listinfo/patches

Reply via email to