1

I have an array (vector, matrix) type that I use subrange on a lot. For example:

x = x + y[i:j]

Does the y[i:j] create a temporary copy before passing the argument to the addition operator?

Thanks!

Matyas
  • 644
  • 6
  • 15
  • 4
    Are we talking about Python array from the array module (https://docs.python.org/2/library/array.html) or NumPy arrays (http://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html)? – James Mills May 20 '14 at 00:07
  • 1
    Any reason for avoiding the use of either `+=` or `.extend`? – g.d.d.c May 20 '14 at 01:22
  • Reason: I was not aware that += and .extend would be better... I thought += is just syntactic sugar. (Also this is existing code I have to take over.) Are they? Maybe they make fewer temp copies, exactly what I need? – Matyas May 20 '14 at 17:42

0 Answers0