A glance at python’s “tagging” of objects

Just learned the hard way about some basics of python’s memory management. For people coming from R or other languages, it might be confusing to realize that if you define

x = [1,2,3]


x = y

and then modify x, for instance through


the change in x will propagate to y. This means that if you query the value of y, you will in fact get


This also means that the sequence

x = [1,2,3]

Is very much different from

x = [1,2,3,4]

For more on this and how to “really” define a new list with some life of its own in the memory, but with the same value as x, see http://henry.precheur.org/python/copy_list.