Difference between shallow copy and deep copy

Shallow copy

Shallow Copy points to the same location in memory as ‘Source’ does. Which essentially means any changes made to the copied item, it will modify the source item as well.

Deep copy

In deep copy it first creates a new object and then recursively populates it with copies of the child objects found in the original. In case of deep copy, a copy of object is copied in other object. It means that any changes made to a copy of object do not reflect in the original object.️

So whenver we do obj1 = obj, that’s a shallow copy. [in Python and Javascript]

原文链接:Difference between shallow copy and deep copy

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容