Python dictionary deepcopy

后端 未结 2 1976
一向
一向 2020-12-30 00:46

I was wondering in how does exactly deepcopy work in the following context:

from copy import deepcopy

def copyExample:
    self.myDict = {}
    firstPositio         


        
2条回答
  •  难免孤独
    2020-12-30 01:35

    The documentation makes it pretty clear that you're getting new copies, not references. Deepcopy creates deep copies for built in types, with various exceptions and that you can add custom copy operations to your user-defined objects to get deep copy support for them as well. If you're not sure, well that's what unit testing is for.

提交回复
热议问题