I wonder if the python interpreter applies copy on write strategy when doing a deepcopy on mutable objects.
Also, I’d like to know if the deepcopy is performed also on nonmutable object (that would seem strange to me however)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It does not do copy-on-write.
It doesn’t do a deep copy on some built-in immutable types, but any user-defined “immutable” types will be deep-copied.
copy.py in the Python 2.7 standard library includes this message in its documentation:
copyhandles immutable objects like this:deepcopyuses a more complicated scheme that’s too long to copy into this most, but the gist is the same. One interesting point is that_deepcopy_tupleiterates through its elements and don’t create a new object until it finds an element that was copied.