<div dir="ltr"><div>With regards to arguments about holding onto large arrays, I would like to emphasize that my original suggestion mentioned weakref'ed numpy arrays. Essentially, the idea is to claw back only the raw memory blocks during that limbo period between discarding the numpy array python object and when python garbage-collects it.<br><br></div>Ben Root<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 2:43 PM, Julian Taylor <span dir="ltr"><<a href="mailto:jtaylor.debian@googlemail.com" target="_blank">jtaylor.debian@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03.10.2016 20:23, Chris Barker wrote:<br>
><br>
><br>
> On Mon, Oct 3, 2016 at 3:16 AM, Julian Taylor<br>
</span>> <<a href="mailto:jtaylor.debian@googlemail.com">jtaylor.debian@googlemail.com</a> <mailto:<a href="mailto:jtaylor.debian@googlemail.com">jtaylor.debian@<wbr>googlemail.com</a>>><br>
<span class="">> wrote:<br>
><br>
>     the problem with this approach is that we don't really want numpy<br>
>     hogging on to hundreds of megabytes of memory by default so it would<br>
>     need to be a user option.<br>
><br>
><br>
> indeed -- but one could set an LRU cache to be very small (few items,<br>
> not small memory), and then it get used within expressions, but not hold<br>
> on to much outside of expressions.<br>
<br>
</span>numpy doesn't see the whole expression so we can't really do much.<br>
(technically we could in 3.5 by using pep 523, but that would be a<br>
larger undertaking)<br>
<span class=""><br>
><br>
> However, is the allocation the only (Or even biggest) source of the<br>
> performance hit?<br>
><br>
<br>
</span>on large arrays the allocation is insignificant. What does cost some<br>
time is faulting the memory into the process which implies writing zeros<br>
into the pages (a page at a time as it is being used).<br>
By storing memory blocks in numpy we would save this portion. This is<br>
really the job of the libc, but these are usually tuned for general<br>
purpose workloads and thus tend to give back memory back to the system<br>
much earlier than numerical workloads would like.<br>
<br>
Note that numpy already has a small memory block cache but its only used<br>
for very small arrays where the allocation cost itself is significant,<br>
it is limited to a couple megabytes at most.<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
</div></div></blockquote></div><br></div>