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

Robert Kern robert.kern@gmail....
Sun Feb 10 20:07:15 CST 2008

On Feb 10, 2008 7:17 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
> > 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.

I say add the out= parameter when you use such an algorithm. But if
you like, just use slice assignment for now.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list