<br><br><div><span class="gmail_quote">On 8/6/07, <b class="gmail_sendername">Anne Archibald</b> <<a href="mailto:peridot.faceted@gmail.com">peridot.faceted@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 06/08/07, David Cournapeau <<a href="mailto:david@ar.media.kyoto-u.ac.jp">david@ar.media.kyoto-u.ac.jp</a>> wrote:<br><br>> Well, when I proposed the SIMD extension, I was willing to implement the<br>> proposal, and this was for a simple goal: enabling better integration
<br>> with many numeric libraries which need SIMD alignment.<br>><br>> As nice as a custom allocator might be, I will certainly not implement<br>> it myself. For SIMD, I think the weight adding complexity / benefit
<br>> worth it (since there is not much change to the API and implementation),<br>> and I know more or less how to do it; for custom allocator, that's an<br>> entirely different story. That's really more complex; static pools may
<br>> be useful in some cases (but that's not obvious, since only the data are<br>> allocated with this buffer, everything else being allocated through the<br>> python memory allocator, and numpy arrays have pretty simple memory
<br>> allocation patterns).<br><br>I have to agree. I can hardly volunteer David for anything, and I<br>don't have time to implement this myself, but I think a custom<br>allocator is a rather special-purpose tool; if one were to implement
<br>one, I think the way to go would be to implement a subclass of ndarray<br>(or just a constructor) that allocated the memory. This could be done<br>from python, since you can make an ndarray from scratch using a given<br>
memory array. Of course, making temporaries be allocated with the<br>correct allocator will be very complicated, since it's unclear which<br>allocator should be used.</blockquote><div><br>Maybe I'm missing something, but handling the temporaries is automatic. Just return the appropriate slice from an array created in a subroutine. The original array gets its reference count decremented when the routine exits but the slice will still hold one. When the slice is deleted all the allocated memory will get garbage collected.
<br></div><br>Chuck<br></div><br>