Pointing of variables in Python
<p>Suppose I create a function <code>A</code> that is used as an argument in another function, so <code>B(A)</code>. Function <code>A</code> points to an entry in a (SciPy) array <code>C</code>. If I change the array <code>C</code> from within <code>B</code>, then the value in the array will be changed globally, so that also <code>A</code> notices that change. Here is an example:</p>

<pre><code>def pointing_test2(inputs, fs):
    local = inputs
    print (local is initial)
    print fs(0)
    local[0] += 1.0
    print fs(0)

initial = sc.array([1.0])
func = lambda x: initial[0]

pointing_test2(initial, func)

------- Output -------
True
1.0
2.0
[ 2.]
</code></pre>

<p>One can avoid that the array <code>C</code> is changed globally by making a copy locally within <code>B</code>, like so:</p>

<pre><code>[...]
        local = inputs.copy()
[...]

------- Output -------
False
1.0
1.0
[ 1.]
</code></pre>

<p>What I want to achieve is midway! I would like to have the function <code>A</code> to point to the copy of the array locally, so within <code>B</code>! In that fashion, the output I desire would be the following:</p>

<pre><code>------- Output -------
False
1.0
2.0
[ 1.]
</code></pre>

<p>How can I achieve this?</p>
