First, the numbers and strings
For the numbers and strings, the assignment, shallow vs. deep copy meaningless, because it always points to the same memory address.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Second, other basic data types
For purposes of dictionaries, tuples, lists, assignment, deep and shallow copy copy, change its memory address is different.
1, the assignment
Assignment , just create a variable that points to the original memory address, such as:
1 2 3 |
|
2, shallow copy
Shallow copy , only the first layer creates the additional data in memory
1 2 3 4 5 |
|
3, deep copy
Deep copy , all of the data in the memory to recreate a copy (excluding the last one, namely: the internal optimization python strings and numbers)
1 2 3 4 5 |
|