"The reasons why deepcopy is so much slower than the dict comprehension + list copy are:
- deepcopy is multi-purpose function - it works for mostly any kind of object
- deepcopy is implemented in python whilst dict comprehension and list slicing is done at lower level
And most imporantly:
- deepcopy makes copies of the elements inside containers recursively, whilst your dict comprehension does not."
Comment
copy.deepcopy is way slower than dict comprehension -
https://stackoverflow.com/questions/20772885/is-python-deepcopy-more-efficient-than-custom-code-or-less-efficient-predictabl
"The reasons why deepcopy is so much slower than the dict comprehension + list copy are:
- deepcopy is multi-purpose function - it works for mostly any kind of object
- deepcopy is implemented in python whilst dict comprehension and list slicing is done at lower level
And most imporantly:
- deepcopy makes copies of the elements inside containers recursively, whilst your dict comprehension does not."