On Wed, Nov 16, 2011 at 5:49 PM, Aaron Bentley <span dir="ltr"><<a href="mailto:aaron@aaronbentley.com">aaron@aaronbentley.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 11-11-16 11:26 AM, Gordon Tyler wrote:</div><div class="im">
> This is just a wild idea, but would using Python generator<br>
> expressions help with keeping only a small part of a large data<br>
> file in memory?<br>
<br>
</div>Not really.  The point is that the data needs to be dealt with in<br>
smaller chunks, whether they're read() from a file directly or<br>
iterated through from a generator.  Dealing with the interface<br>
difference between files and iterables is the easy bit.  It's avoiding<br>
reading entire files at once that seems to be problematic.<br></blockquote><div><br></div><div>Why is the whole file needed in memory at once?</div><div>If it is read into a string, it would be quite easy to create a "virtual" string handling "paging" of the file.</div>
<div>This would provide the same functionality as mmap(), but without the 32 bit or OS-specific limitations.</div><div>It would be different if it is needed to handle writes, where the written file is expected to be handled by an unknown consumer (a pipe for example).</div>
<div><br></div><div>Marco</div><div><br></div></div>-- <br>Marco Pantaleoni<br><br>