---
title: "What is the difference between deep copy and shallow copy?"  
description: "What is the difference between deep copy and shallow copy?"  
author: "ICSM Computer"  
published: 2025-03-27  
updated: 2025-04-20  
canonical: https://www.mindstick.com/forum/161374/what-is-the-difference-between-deep-copy-and-shallow-copy  
category: "python"  
tags: ["python"]  
reading_time: 2 minutes  

---

# What is the difference between deep copy and shallow copy?

What is the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between [deep](https://yourviews.mindstick.com/view/87451/a-journey-into-the-deep-dubai-s-underwater-wonderland) [copy and shallow](https://www.mindstick.com/interview/33945/discuss-the-differences-between-deep-copy-and-shallow-copy-in-java-objects) copy?

## Replies

### Reply by Khushi Singh

Programming offers two standard methods for object duplication within the [Python language](https://www.mindstick.com/articles/23325/3-amazing-python-news-and-opinion-podcasts): shallow [copy](https://www.mindstick.com/forum/161993/explain-the-numpy-array-copy-vs-view-with-example) and deep copy. The proper distinction between shallow and deep copy methods remains essential to control data management and prevent accidental modifications.

Through a shallow copy you get a new object which keeps the references to existing nested objects. References to original objects are not duplicated during the copying process. The modifications made to nested objects (such as lists embedded within lists) will become evident in both the original and replicated object. In Python code you can produce a shallow copy through the use of `copy.copy()` function.

## Example:

```python
import copy
original = [[1, 2], [3, 4]]
shallow = copy.copy(original)
shallow[0][0] = 99
print(original)  # Output: [[99, 2], [3, 4]]
```

The inner list remains non-independent between both variables because deep copying did not split the reference.

When using deep copy, programmers make an original and then perform a complete object-to-object copy process of nested structures. The original content together with its duplicate operate as self-contained entities that maintain no relationship between them. Any modifications executed on the deep copy fail to influence the primary object. Python utilizes `copy.deepcopy()` as the function to produce deep copies in its [programming](https://www.mindstick.com/articles/336773/best-programming-languages-to-learn-in-2024-and-how-mindstick-can-help) environment.

## Example:

```python
import copy
original = [[1, 2], [3, 4]]
deep = copy.deepcopy(original)
deep[0][0] = 99
print(original)  # Output: [[1, 2], [3, 4]]
```

The initial list remains untouched during this operation.

## Summary:

- The outer part of the object duplicates through the shallow copy method, though it still shares references for nested elements.\
- Deep object copying results in an entirely separate duplicate which duplicates all enclosed elements.

The selection between deep and shallow copy decision stems from the program demands alongside the data organization structure.


---

Original Source: https://www.mindstick.com/forum/161374/what-is-the-difference-between-deep-copy-and-shallow-copy

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
