[Numpy-discussion] memory allocation at assignment
Thu Jun 28 08:35:48 CDT 2012
(on a mobile)
On Jun 28, 2012, at 1:20 AM, Pierre Haessig <email@example.com> wrote:
> Le 28/06/2012 02:34, Nathaniel Smith a écrit :
>> Yes it does. If you want to avoid this extra copy, and have a
>> pre-existing output array, you can do:
>> np.add(a, b, out=c)
> And is there a temporary copy when using inplace operators like:
> c = a.copy()
> c += b
> Is there a temporary (c+b) array which is then assigned to c, or is it really an inplace assignment as the operator += would suggest ?
It really is inplace. As Nathaniel mentioned --- all ufuncs take an out keyword.
The inplace mechanism uses this so that one input and the output are the same.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion