def deepcopy(obj, recursion=100000):
"""
Perform a deep copy of obj using cPickle. Faster than copy.deepcopy()
for large objects.
@param obj: the object to copy
@return: a deep copy of obj
@param recursion: maximum recursion limit
@type recursion: int
"""
from csb.io import Pickle
current = sys.getrecursionlimit()
sys.setrecursionlimit(recursion)
tmp = Pickle.dumps(obj, Pickle.HIGHEST_PROTOCOL)
copy = Pickle.loads(tmp)
sys.setrecursionlimit(current)
return copy
评论列表
文章目录