[Numpy-discussion] Setting contents of buffer for array object

Matthew Brett matthew.brett@gmail....
Sun Feb 10 19:17:02 CST 2008


> Ah, I see. You definitely do not want to reassign the .data buffer in
> this case. An out= parameter does not reassign the memory location
> that the array object points to. It should use the allocated memory
> that was already there. It shouldn't "copy" anything at all;
> otherwise, "median(x, out=out)" is no better than "out[:] =
> median(x)". Personally, I don't think that a function should expose an
> out= parameter unless if it can make good on that promise of memory
> efficency.

I agree - but there are more efficient median algorithms out there
which can make use of the memory efficiently.  I wanted to establish
the call signature to allow that.  I don't feel strongly about it
though.

> Can you show us the current implementation that you have?

is attached, comments welcome...

Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mymedian.py
Type: text/x-python
Size: 2492 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080211/88380c96/attachment-0001.py 


More information about the Numpy-discussion mailing list