def save_func(self, obj):
try:
self.save_global(obj)
return
except pickle.PicklingError:
pass
assert type(obj) is types.FunctionType
self.save(types.FunctionType)
self.save((
obj.func_code,
obj.func_globals,
obj.func_name,
obj.func_defaults,
obj.func_closure,
))
self.write(pickle.REDUCE)
if id(obj) not in self.memo: # Could be if we recursively landed here. See also pickle.save_tuple().
self.memoize(obj)
评论列表
文章目录