Python Forum

Full Version: assign a value to a dict change all the values
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Say you have a container with memory locations (references) in it.

A normal copy (x = y) just copies the memory location of the container.

A shallow copy (x = y[:]) makes a new container, with the memory locations that were in the old container.

A deep copy (x = deepcopy(y)) makes a new container, with new versions of anything that is just a memory location in the old container.
Pages: 1 2