예제 #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)
예제 #2
0
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!")
예제 #3
0
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
예제 #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)
예제 #5
0
파일: pool.py 프로젝트: crobinsonut/joblib
 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)
예제 #6
0
 def __init__(self, *args, **kwds):
     Pickler.__init__(self, *args, **kwds)
예제 #7
0
 def __init__(self, *args):
     Pickler.__init__(self, *args)
     self.dispatch_table = dispatch_table.copy()
     self.dispatch_table.update(self._extra_reducers)