Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Deep vs Shallow Copies in Python (Summary)

By now, you’ve explored various techniques for copying Python objects, including constructors, slicing, the .copy() method, and the copy module. Along the way, you’ve learned about shallow vs deep copies and how Python’s assignment statements create bindings rather than copies. You also delved into the mechanics of scalar and composite types, mutable and immutable objects, and how these characteristics influence copying behavior.

In this video course, you’ve learned how to:

  • Differentiate between shallow and deep copies
  • Use Python’s copy module for versatile object copying
  • Implement custom copying behavior in your own classes
  • Apply various techniques to copy different types of objects efficiently

Resources linked in this lesson:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

00:00 Hey, you finished Deep vs Shallow Copies in Python. Well done. You now know so much more about object copying from the motivations and foundations of copying to circumstances where objects are copied versus aliased, and even how the characteristics of Python objects, whether they’re user-defined or built-in affect copying.

00:21 I hope this course has inspired you to continue to think deeply about subjects that may seem simple on the surface, but really have nuance and complexity. Throughout this course, you’ve learned various techniques for copying objects in Python, the differences between shallow and deep copying, how to distinguish between references and values, the benefits of Python’s built-in copy module, as well as ways to fine-tune the copy behavior of your own classes.

00:47 And if you liked this, there’s even more information about copying in the tutorial this course is based on. For more details on the copy module, a deeper dive into deep copying and even more example code, check out How to Copy Objects in Python: Shallow vs Deep Copy Explained.

01:05 Or maybe you’re looking for something different. To understand how to further customize your classes to work with Python built-ins, I recommend Python’s Magic Methods in Classes.

01:15 Did that last lesson pique your interest in context managers? Well then head on over to Context Managers and Python’s with Statement, and if you’d just like to improve your code overall, Python Code Quality: Best Practices and Tools is an essential read.

01:32 Again, this has been Joseph, or at least some intelligence that shares his thoughts, feelings, and experiences. Regardless, thanks for watching.

Become a Member to join the conversation.