copy.deepcopy raises TypeError on objects with self-defined __new__() method

后端 未结 3 1661
盖世英雄少女心
盖世英雄少女心 2021-01-17 20:42

I want to implement a symbol type, which keeps track of the symbols we already have(saved in _sym_table), and return them if they exist, or create new ones othe

3条回答
  •  旧巷少年郎
    2021-01-17 21:08

    Define __getnewargs__ — that way you will not only be able to copy and deepcopy, but you'll also be able to pickle.

提交回复
热议问题