Python: Copy

Shallow copy v.s. Deep copy

The difference between shallow and deep copying is only relevant for compound objects

  • A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.

  • A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original.

read more

  • 图解 Python 深拷贝和浅拷贝

  • copy — Shallow and deep copy operations¶

你可能感兴趣的