Exemple #1
0
 def __init__(self, writer, reducers=None, protocol=HIGHEST_PROTOCOL):
     Pickler.__init__(self, writer, protocol=protocol)
     if reducers is None:
         reducers = {}
     # Make the dispatch registry an instance level attribute instead of
     # a reference to the class dictionary under Python 2
     self.dispatch = Pickler.dispatch.copy()
     for type, reduce_func in reducers.items():
         self.register(type, reduce_func)
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
Exemple #4
0
 def __init__(self, writer, reducers=None, protocol=HIGHEST_PROTOCOL):
     Pickler.__init__(self, writer, protocol=protocol)
     if reducers is None:
         reducers = {}
     if hasattr(Pickler, 'dispatch'):
         # Make the dispatch registry an instance level attribute instead of
         # a reference to the class dictionary under Python 2
         self.dispatch = Pickler.dispatch.copy()
     else:
         # Under Python 3 initialize the dispatch table with a copy of the
         # default registry
         self.dispatch_table = copyreg.dispatch_table.copy()
     for type, reduce_func in reducers.items():
         self.register(type, reduce_func)
Exemple #5
0
 def __init__(self, writer, reducers=None, protocol=HIGHEST_PROTOCOL):
     Pickler.__init__(self, writer, protocol=protocol)
     if reducers is None:
         reducers = {}
     if hasattr(Pickler, 'dispatch'):
         # Make the dispatch registry an instance level attribute instead of
         # a reference to the class dictionary under Python 2
         self.dispatch = Pickler.dispatch.copy()
     else:
         # Under Python 3 initialize the dispatch table with a copy of the
         # default registry
         self.dispatch_table = copyreg.dispatch_table.copy()
     for type, reduce_func in reducers.items():
         self.register(type, reduce_func)
Exemple #6
0
 def __init__(self, *args, **kwds):
     Pickler.__init__(self, *args, **kwds)
Exemple #7
0
 def __init__(self, *args):
     Pickler.__init__(self, *args)
     self.dispatch_table = dispatch_table.copy()
     self.dispatch_table.update(self._extra_reducers)