Feb-16-2017, 07:05 PM
There's a difference between a value (as B is) and a list (as T is).
If my understanding of python is correct (I'm not absolute sure in this point), then
However, T links to a list. And you will not get a copy of this list, but another link to this list. And the list items are not immutable. Therefore, when you change them, the change will apply to both links, originT and T.Â
Therefore, even if the expressions look excactly the same, different things happen, because one of the starting items is a number and the other one is not.
I only wonder why the "fast copy" does not work. Unfortunately, I can't do experiments with your code by myself, as I don't have mathplotlib. Maybe try other ways to get a copy?
If my understanding of python is correct (I'm not absolute sure in this point), then
originB = B
makes originB being the same as B, that is, whatever number B is at that time. If I am not wrong, it's kind of a link to a number, and as this number itself is immutable, B = B + cte
cannot change originB's target. Therefore, only B is changed. However, T links to a list. And you will not get a copy of this list, but another link to this list. And the list items are not immutable. Therefore, when you change them, the change will apply to both links, originT and T.Â
Therefore, even if the expressions look excactly the same, different things happen, because one of the starting items is a number and the other one is not.
I only wonder why the "fast copy" does not work. Unfortunately, I can't do experiments with your code by myself, as I don't have mathplotlib. Maybe try other ways to get a copy?