deepcopy support
from copy import deepcopy
from procset import ProcSet
i = ProcSet(*[1,2,5,6])
d = {1: i }
deepcopy(d)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-94984bb7c054> in <module>()
----> 1 deepcopy(d)
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
153 copier = _deepcopy_dispatch.get(cls)
154 if copier:
--> 155 y = copier(x, memo)
156 else:
157 try:
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _deepcopy_dict(x, memo)
241 memo[id(x)] = y
242 for key, value in x.items():
--> 243 y[deepcopy(key, memo)] = deepcopy(value, memo)
244 return y
245 d[dict] = _deepcopy_dict
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
180 raise Error(
181 "un(deep)copyable object of type %s" % cls)
--> 182 y = _reconstruct(x, rv, 1, memo)
183
184 # If is its own copy, don't memoize.
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _reconstruct(x, info, deep, memo)
295 if state is not None:
296 if deep:
--> 297 state = deepcopy(state, memo)
298 if hasattr(y, '__setstate__'):
299 y.__setstate__(state)
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
153 copier = _deepcopy_dispatch.get(cls)
154 if copier:
--> 155 y = copier(x, memo)
156 else:
157 try:
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _deepcopy_tuple(x, memo)
221
222 def _deepcopy_tuple(x, memo):
--> 223 y = [deepcopy(a, memo) for a in x]
224 # We're not going to put the tuple in the memo, but it's still important we
225 # check for it, in case the tuple contains recursive mutable structures.
/home/auguste/prog/env3.5/lib/python3.5/copy.py in <listcomp>(.0)
221
222 def _deepcopy_tuple(x, memo):
--> 223 y = [deepcopy(a, memo) for a in x]
224 # We're not going to put the tuple in the memo, but it's still important we
225 # check for it, in case the tuple contains recursive mutable structures.
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
153 copier = _deepcopy_dispatch.get(cls)
154 if copier:
--> 155 y = copier(x, memo)
156 else:
157 try:
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _deepcopy_dict(x, memo)
241 memo[id(x)] = y
242 for key, value in x.items():
--> 243 y[deepcopy(key, memo)] = deepcopy(value, memo)
244 return y
245 d[dict] = _deepcopy_dict
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
153 copier = _deepcopy_dispatch.get(cls)
154 if copier:
--> 155 y = copier(x, memo)
156 else:
157 try:
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _deepcopy_list(x, memo)
216 memo[id(x)] = y
217 for a in x:
--> 218 y.append(deepcopy(a, memo))
219 return y
220 d[list] = _deepcopy_list
/home/auguste/prog/env3.5/lib/python3.5/copy.py in deepcopy(x, memo, _nil)
180 raise Error(
181 "un(deep)copyable object of type %s" % cls)
--> 182 y = _reconstruct(x, rv, 1, memo)
183
184 # If is its own copy, don't memoize.
/home/auguste/prog/env3.5/lib/python3.5/copy.py in _reconstruct(x, info, deep, memo)
290 if deep:
291 args = deepcopy(args, memo)
--> 292 y = callable(*args)
293 memo[id(x)] = y
294
/home/auguste/prog/env3.5/lib/python3.5/copyreg.py in __newobj__(cls, *args)
86
87 def __newobj__(cls, *args):
---> 88 return cls.__new__(cls, *args)
89
90 def __newobj_ex__(cls, args, kwargs):
TypeError: __new__() missing 1 required positional argument: 'sup'
@bleuse: edited to use pretty printed code
Edited by Raphaël Bleuse