Closed drewrisinger closed 5 years ago
This is the correct behavior. If you run your "broken" test_python_array
method on the host Python, you will get the exact same result.
Fine. That seems like an inconsistent use of pass-by-reference/pass-by-value in the Python interpreter, though. Odd.
It is consistent (even if perhaps confusing) - you just have to know that the *
operator on a list does a shallow copy of the element. Does the code below make it clearer?
>>> x = [0]
>>> id(x)
140512082107016
>>> l=[x]*2
>>> l
[[0], [0]]
>>> l[0][0] = 1
>>> l
[[1], [1]]
>>> id(l[0])
140512082107016
>>> id(l[1])
140512082107016
Bug Report
One-Line Summary
Issues with references when allocating multi-dimensional array on core.
Issue Details
Steps to Reproduce
Sample code:
Expected Behavior
Both methods should do produce exactly the same behavior
Actual (undesired) Behavior
Your System