[Numpy-discussion] memory allocation at assignment
Thu Jun 28 08:28:58 CDT 2012
Yes, the creation of the tmp *is* the creation of a new NumPy array. So, it is as expensive.
(on a mobile)
On Jun 28, 2012, at 12:44 AM, srean <firstname.lastname@example.org> wrote:
>> 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)
>> ('+' on numpy array's is just a synonym for np.add; np.add is a ufunc,
>> and all ufunc's accept this syntax:
> Is the creation of the tmp as expensive as creation of a new numpy
> array or is it somewhat lighter weight (like being just a data
> buffer). I sometimes use the c[:] syntax thinking I might benefit from
> numpy.array re-use. But now I think that was misguided.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion