<div dir="ltr"><div><div><div>Hi Mark,<br><br></div>Having an `out` might make sense. With present numpy, if you are really dealing with a file or file-like object, you might consider using `np.memmap` to access the data more directly. If it is something that looks more like a buffer, `np.frombuffer` may be useful (that doesn't copy data, but points the array at the memory that holds the buffer).<br><br></div>All the best,<br><br></div>Marten<br><br> </div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 4, 2018 at 10:35 PM Mark Harfouche <<a href="mailto:mark.harfouche@gmail.com">mark.harfouche@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="m_8648149541910764114markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important">I was wondering what would your thoughts be on adding an output parameter to np.fromfile?</p>
<p style="margin:0px 0px 1.2em!important">The advantage would be when interfacing with executables like <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">ffmpeg</code> which are arguably easier to use by calling them as a subprocess compared to a shared library in python.</p>
<p style="margin:0px 0px 1.2em!important">Having the output parameter in <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">np.fromfile</code> would enable pre-allocation of large arrays that are reused during the computation of new image frames when decoding large video files.</p>
<p style="margin:0px 0px 1.2em!important">Thoughts are appreciated!</p>
<p style="margin:0px 0px 1.2em!important">Mark</p>
<div title="MDH:PGRpdj5JIHdhcyB3b25kZXJpbmcgd2hhdCB3b3VsZCB5b3VyIHRob3VnaHRzIGJlIG9uIGFkZGlu
ZyBhbiBvdXRwdXQgcGFyYW1ldGVyIHRvIG5wLmZyb21maWxlPzwvZGl2PjxkaXY+PGJyPjwvZGl2
PjxkaXY+VGhlIGFkdmFudGFnZSB3b3VsZCBiZSB3aGVuIGludGVyZmFjaW5nIHdpdGggZXhlY3V0
YWJsZXMgbGlrZSBgZmZtcGVnYCB3aGljaCBhcmUgYXJndWFibHkgZWFzaWVyIHRvIHVzZSBieSBj
YWxsaW5nIHRoZW0gYXMgYSBzdWJwcm9jZXNzIGNvbXBhcmVkIHRvIGEgc2hhcmVkIGxpYnJhcnkg
aW4gcHl0aG9uLjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+SGF2aW5nIHRoZSBvdXRwdXQgcGFy
YW1ldGVyIGluIGBucC5mcm9tZmlsZWAgd291bGQgZW5hYmxlIHByZS1hbGxvY2F0aW9uIG9mIGxh
cmdlIGFycmF5cyB0aGF0IGFyZSByZXVzZWQgZHVyaW5nIHRoZSBjb21wdXRhdGlvbiBvZiBuZXcg
aW1hZ2UgZnJhbWVzIHdoZW4gZGVjb2RpbmcgbGFyZ2UgdmlkZW8gZmlsZXMuPC9kaXY+PGRpdj48
YnI+PC9kaXY+PGRpdj5UaG91Z2h0cyBhcmUgYXBwcmVjaWF0ZWQhPC9kaXY+PGRpdj48YnI+PC9k
aXY+PGRpdj5NYXJrPGJyPjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>