Copy depth on the Python

 Before always thought that the first layer is shallow copy copy content, but do not open up the memory, just add a new point to the original content; deep copy is a copy of a copy of each layer and open up memory.

In fact, this is not rigorous incorrect.

 

 

 

 From the above it can be seen, a shallow copy was variable type, the memory is changed, that is opened up memory, but can not change the type of memory when the address does not change.

Summary: shallow copy is a copy of the content data, to create a reference point to an immutable type, the variable type of the memory it is stored, but only copy of the first layer. Deep copy is a copy of each layer variable data types and open up the memory, but immutable types simply create a reference.

Guess you like

Origin www.cnblogs.com/blackball9/p/11529806.html