def save(obj, filename): print("* Saving...") setrecursionlimit(10000) #copy_reg.pickle(types.MethodType, _pickle_method, _unpickle_method) with open(filename, "wb") as out_file: pickler = Pickler(out_file, -1) pickler.persistent_id = persistent_id pickler.dump(obj) print("* Saved!")
def dump(obj): print("* Dumping...") setrecursionlimit(10000) #copy_reg.pickle(types.MethodType, _pickle_method, _unpickle_method) pickle_buffer = StringIO() pickler = Pickler(pickle_buffer, -1) pickler.persistent_id = persistent_id pickler.dump(obj) print("* Dumped!") return pickle_buffer