<p>基本的是我需要以每行为基础处理4gig文本文件。在</p>
<p>在f中使用.readline()或for line对内存很好,但是IO需要很长时间。我想用屈服点之类的东西,但那(我想)会砍掉线条。在</p>
<p><strong>可能的答案:</strong></p>
^{1}$
<blockquote>
<pre><code>Read until EOF using readline() and return a list containing the lines
</code></pre>
<p>thus read. If the optional sizehint
argument is present, instead of
reading up to EOF, whole lines
totalling approximately sizehint bytes
(possibly after rounding up to an
internal buffer size) are read.
Objects implementing a file-like
interface may choose to ignore
sizehint if it cannot be implemented,
or cannot be implemented efficiently.</p>
</blockquote>
<p>没想到你能做到!在</p>
<p>你总是能把台词拼凑起来吗?我的意思是当你可以打开同一个文件6次并进行迭代时,为什么要打开一个文件并一直迭代呢。
e、 g</p>
<pre><code>a #is the first 1024 bytes
b #is the next 1024
#etcetc
f #is the last 1024 bytes
</code></pre>
<p>每个文件句柄运行在一个单独的进程中,我们开始用煤气做饭。只需记住正确处理行尾。在</p>