Time to time I need to deepcopy an object and sometimes it's a dictionary object so I use **
operator to copy it easily but I always wondered if deepcopy is any different or efficient in some sense.
Which one is more efficient in terms of memory footprint, cpu time and does deepcopy iterate over like **
operator does?
import copy
myObj = {"some": "data", "to": "copy"}
# With using unpacking operator.
newObj1 = {**myObj}
# With using `copy.deepcopy` function.
newObj2 = copy.deepcopy(myObj)