title: NumPy: Erroneous result when modifying array using itself
body: <pre><code>import numpy as np
  bc = np.arange(10) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  # regular way using NumPy function
  np.diff(bc) # array([1, 1, 1, 1, 1, 1, 1, 1, 1])
  
  # something similar with array subtraction:
  bc[1:] - bc[:-1] # array([1, 1, 1, 1, 1, 1, 1, 1, 1])
  
  # but this does the wrong thing:
  bc[1:] -= bc[:-1] # array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5])
  </code></pre>
  
  <p>As a C and C++ programmer I can understand why this happens (it's memcpy() instead of memmove() all over again), but it seems like end users of Python and NumPy might not expect this.  And I failed to find any documentation saying this wouldn't work.</p>
  
  <p>The question is: is there a bug in NumPy here (probably not), or is there some NumPy documentation explaining what the rules are in situations like this, or is that missing from the documentation?</p>
  
  <p>Secondly, I would like to figure out a safe, working solution which is quasi-optimal in space and time.  That is, it should not allocate memory beyond a constant amount, and it should not be a silly pure-Python "for" loop.  :)  Those are the goals one might hope to achieve with the in-place modification which clearly doesn't work.</p>
  
  <p>I'm using NumPy 1.8.0.</p>