what is shallow copy deep copy general difference between shallow copy and deep copy in python

Опубликовано: 07 Июль 2026
на канале: in code
19
0

difference between general shallow and deep copy in python what is shallow copy deep copy general copy difference

documentation
https://jiyasolution.blogspot.com/202...

copy:
is the process in which transferring the same data from one source to another destination, the types of transferring the data can also be called the copy of data. a copy can be classified into three types

copy: is the process of transferring the data from source to a destination called copy

types :
general copy
shallow copy
deep copy
from copy import deepcopy #protect data

source = [0,100,[1,3,9], "aaa", "bbb"]

#general copy
#dest = source
#item and nested item will change

#shallow copy
#dest = source.copy()
items will not modify the items but nested items will modifies

#deep copy
dest = deepcopy(source)
#neither items nor modifying nested items

dest[0]=10
dest[2][1]=300