[Numpy-discussion] memory allocation at assignment
Chris Barker
chris.barker at noaa.gov
Thu Jun 28 14:04:31 EDT 2012
On Thu, Jun 28, 2012 at 9:06 AM, Pierre Haessig
> On the other hand, just like srean mentionned, I think I also misused
> the "c[:] = a+b" syntax.
> I feel it's a bit confusing since this way of writing the assignment
> really feels likes it happens inplace. Good to know it's not the case.
well, c is being modified in place -- it's the a+b that is creating a new array.
so if you have a c around for another purpose (other than to store the
result of a+b -- it might make sense to use this approach. Though a
little faster might be:
c[:] = a
c += b
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list