title: Numpy interfering with namespace
body: <pre><code>import numpy as np
  
  def f(x):
      x /= 10
  
  data = np.linspace(0, 1, 5)
  print data
  f(data)
  print data
  </code></pre>
  
  <p>Output on my system (debian 8, Python 2.7.9-1, numpy 1:1.8.2-2)</p>
  
  <pre><code>[ 0. 0.25  0.5   0.75  1.  ]
  [ 0. 0.025  0.05   0.075  0.1  ]
  </code></pre>
  
  <p>Normally I would expect <code>data</code> to stay untouched when passing it to a function as this has its own separate namespace. But when the data is a numpy array the function changes <code>data</code> globally.</p>
  
  <p>Is this a feature, a bug or am I maybe missing something? How should I avoid this behavior when using a custom plot function to scale my data automatically?</p>
  
  <p><strong>UPDATE</strong>
  (<em>See Kevin J. Chase's answer for more details</em>)</p>
  
  <pre><code>import numpy as np
  
  def f(x):
      print id(x)
      x = x/10
      print id(x)
  
  data = np.linspace(0, 1, 5)
  print id(data)
  print data
  f(data)
  print data
  </code></pre>
  
  <p>Output on my system (debian 8, Python 2.7.9-1, numpy 1:1.8.2-2)</p>
  
  <pre><code>48844592
  [ 0. 0.25  0.5   0.75  1.  ]
  48844592
  45972592
  [ 0. 0.25  0.5   0.75  1.  ]
  </code></pre>
  
  <p>Using <code>x = x/10</code> instead of <code>x /= 10</code> solves the problem for me. </p>
  
  <p>The behaviour of the nice and short <code>x /= 10</code> statement actually depends heavily on the <em>type of x</em>. It rebinds if x is immutable and mutates otherwise.</p>
  
  <p>It is not equivalent to <code>x = x/10</code> which always rebinds.</p>
  
  <p>A numpy array is a mutable object.</p>