Should I use `readinto` method of python file or not?
<p>I've recently meet the <code>readinto</code> method of <code>file</code> object (in Python 2.7), it is similar to <code>fread</code> in C. It seems to be convenient and powerful in some case. I plan to use it to read several files into one pre-allocated numpy array <strong>without data copied</strong>.</p>

<p>e.g.</p>

<pre><code>a = np.empty(N)
b = memoryview(a)
fp1.readinto(b[0:100])
fp2.readinto(b[100:200])
</code></pre>

<p>and</p>

<pre><code>fp1.readinto(b[0:100])
fp1.seek(400, 1)
fp1.readinto(b[100:200])
</code></pre>

<p>I've used <code>Cython</code> and <code>fread</code> to do this before I met <code>readinto</code>. So I'm very happy to know a pure python solution.</p>

<p>However its document string says,</p>

<pre><code>file.readinto?
Type:        method_descriptor
String form: &lt;method 'readinto' of 'file' objects&gt;
Namespace:   Python builtin
Docstring:   readinto() -&gt; Undocumented.  Don't use this; it may go away.
</code></pre>

<p><strong>Don't use this</strong>? What happend?</p>

<p>So I'm confused, should I use <code>readinto</code> or not? It may cause any unwanted problem?</p>

<p>Is there any alternative implementation for the code above without <code>readinto</code> but also <strong>avoid data copy</strong>? (To avoid copy means <code>np.concatenate</code> or <code>np.stack</code> is not a good choice.)</p>

<p>Any sugguestion is welcome!  Thank you.</p>

<p>-------upate-------</p>

<p>It seems that I can use <code>io.FileIO</code> in standard library instead of the build-in function <code>open</code>. It looks OK so I've post it as an answer.</p>

<p>Any comment or other solution is still welcome! </p>

<p>-------upate-------</p>

<p>If you meet the same problem, you may want to have a look at the comments below by<br>
Andrea Corbellini and Padraic Cunningham.</p>