copy -> shallowcopy and deepcopy -> copy ?

I recently ran into this bug as only made a shallow copy of an array of arrays. Consequently the reference array was mutated afterwards and it took me quite some time to realise that copy is a “shallow copy”. Wouldn’t it be much more intuitive if copy would do a deep copy and something like shallowcopy is used for shallow copies? I know now when to use deepcopy, but I think many other users will run into the same issue.


Or perhaps keep deepcopy as it is, and rename copy to shallowcopy. This would resolve any ambiguity.

1 Like

I think copy → shallowcopy and deepcopy → copy is a good idea: the no-brainer is the current deepcopy, thus should be the first stop. Why not post it to


Didn’t know about that thread, I’ll post it there, thanks!

I believe copy (shallow) is was is needed most of the time, so I would prefer the status quo. It’s already documented to be shallow, though its docstring could be improved to have a reference to deepcopy.

FWIW, copy and deepcopy are used by Python too. In Swift, copies are shallow by default.


Yes, this is not exactly a novel nomenclature – these are very standard names with similar behavior across various programming languages.