<br>A code snippet would work wonders in making sure you've communicated what you really need, or at least what you have now.<br><br>But if you read the data into one big string, that'll be much more efficient than if you read it as a list of integers or even as a list of lines.<br>
<br>Processing the data one chunk or one line at a time will be far more memory-efficient.<br><br><div class="gmail_quote">2011/8/1 Tong Zhang <span dir="ltr"><<a href="mailto:warriorlance@gmail.com">warriorlance@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div link="blue" vlink="purple" lang="ZH-CN"><div><p class="MsoNormal"><span lang="EN-US">Hello, everyone!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">I am trying to read a little big txt file (~1 GB) by python2.7, what I want to do is to read these data into a array, meanwhile, I monitor the memory cost, I found that it cost more than 6 GB RAM! So I have two questions:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">1: How to estimate memory cost before exec python script?<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">2: How to save RAM while do not increase exec time?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Any answer will be grateful!<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">--Tony Zhang<u></u><u></u></span></p></div></div><br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>