---
title: "What is the difference between deepcopy and shallowcopy?"  
description: "What is the difference between deepcopy and shallowcopy?"  
author: "ICSM Computer"  
published: 2025-08-27  
updated: 2025-08-28  
canonical: https://www.mindstick.com/interview/34361/what-is-the-difference-between-deepcopy-and-shallowcopy  
category: "python"  
tags: ["python-3.4", "Python 3"]  
reading_time: 1 minute  

---

# What is the difference between deepcopy and shallowcopy?

## Answer:

- [**Shallow Copy**](https://www.mindstick.com/interview/22794/difference-between-shallow-copy-and-deep-copy) → Copies only the references, so nested objects are still shared between the original and the copy.
- [**Deep Copy**](https://www.mindstick.com/category/forum/python) → Creates a completely independent copy, including all nested objects, so changes in one won’t affect the other.

```python
import copy
a = [[10, 20], [30, 40]]
shallow = copy.copy(a)
deep = copy.deepcopy(a)

a[0][0] = 990
print(shallow)  # [[990, 20], [30, 40]] (affected)
print(deep)     # [[10, 20], [30, 40]] (not affected)
```

## Answers

### Answer by ICSM Computer

## Answer:

- [**Shallow Copy**](https://www.mindstick.com/interview/22794/difference-between-shallow-copy-and-deep-copy) → Copies only the references, so nested objects are still shared between the original and the copy.
- [**Deep Copy**](https://www.mindstick.com/category/forum/python) → Creates a completely independent copy, including all nested objects, so changes in one won’t affect the other.

```python
import copy
a = [[10, 20], [30, 40]]
shallow = copy.copy(a)
deep = copy.deepcopy(a)

a[0][0] = 990
print(shallow)  # [[990, 20], [30, 40]] (affected)
print(deep)     # [[10, 20], [30, 40]] (not affected)
```


---

Original Source: https://www.mindstick.com/interview/34361/what-is-the-difference-between-deepcopy-and-shallowcopy

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
