efficient 'tail' implementation

bonono at gmail.com bonono at gmail.com
Thu Dec 8 08:29:34 CET 2005


Mike Meyer wrote:
> It would probably be more efficient to read blocks backwards and paste
> them together, but I'm not going to get into that.
>
That actually is a pretty good idea. just reverse the buffer and do a
split, the last line becomes the first line and so on. The logic then
would be no different than reading from beginning of file. Just need to
keep the last "half line" of the reversed buffer if the wanted one
happens to be across buffer boundary.




More information about the Python-list mailing list