There is also a more general solution: the reverse file iterator, <span style="background-color: transparent; ">started here but never </span><div><span style="background-color: transparent; ">finished: </span><a href="http://bugs.python.org/issue1677872" style="background-color: transparent; ">http://bugs.python.org/issue1677872</a><div>
<div><br></div></div>- John<br>
<br><br><div class="gmail_quote">On Tue, Nov 8, 2011 at 1:27 PM, Giampaolo Rodolą <span dir="ltr"><<a href="mailto:g.rodola@gmail.com">g.rodola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Edit: after a better look it seems data gets stored in memory<br>
increasingly. We can see whether that is fixable someway though.<br>
<div class="im"><br>
--- Giampaolo<br>
<a href="http://code.google.com/p/pyftpdlib/" target="_blank">http://code.google.com/p/pyftpdlib/</a><br>
<a href="http://code.google.com/p/psutil/" target="_blank">http://code.google.com/p/psutil/</a><br>
<br>
<br>
</div>2011/11/8 Giampaolo Rodolą <<a href="mailto:g.rodola@gmail.com">g.rodola@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> This is something I need to do every once in a while and I think it<br>
> would be a good addition for shutil module.<br>
> Here:<br>
> <a href="http://stackoverflow.com/questions/136168/get-last-n-lines-of-a-file-with-python-similar-to-tail" target="_blank">http://stackoverflow.com/questions/136168/get-last-n-lines-of-a-file-with-python-similar-to-tail</a><br>

> ...is a nice implementation which appears to be a good compromise in<br>
> terms of speed and memory consumption (it reads the file in chunks, no<br>
> more than 1024 bytes per-read).<br>
><br>
> What do you think?<br>
><br>
> --- Giampaolo<br>
> <a href="http://code.google.com/p/pyftpdlib/" target="_blank">http://code.google.com/p/pyftpdlib/</a><br>
> <a href="http://code.google.com/p/psutil/" target="_blank">http://code.google.com/p/psutil/</a><br>
><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br></div>