Python pickle.__builtins__() Examples
The following are 7
code examples of pickle.__builtins__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pickle
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: cloudpickle.py From spark-cluster-deployment with Apache License 2.0 | 6 votes |
def _make_skel_func(code, num_closures, base_globals = None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ #build closure (cells): if not ctypes: raise Exception('ctypes failed to import; cannot build function') cellnew = ctypes.pythonapi.PyCell_New cellnew.restype = ctypes.py_object cellnew.argtypes = (ctypes.py_object,) dummy_closure = tuple(map(lambda i: cellnew(None), range(num_closures))) if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ return types.FunctionType(code, base_globals, None, None, dummy_closure) # this piece of opaque code is needed below to modify 'cell' contents
Example #2
Source File: cloudpickle.py From FATE with Apache License 2.0 | 5 votes |
def _make_skel_func(code, cell_count, base_globals=None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ closure = ( tuple(_make_empty_cell() for _ in range(cell_count)) if cell_count >= 0 else None ) return types.FunctionType(code, base_globals, None, None, closure)
Example #3
Source File: cloudpickle.py From FATE with Apache License 2.0 | 5 votes |
def _make_skel_func(code, cell_count, base_globals=None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ closure = ( tuple(_make_empty_cell() for _ in range(cell_count)) if cell_count >= 0 else None ) return types.FunctionType(code, base_globals, None, None, closure)
Example #4
Source File: cloudpickle.py From LearningApacheSpark with MIT License | 5 votes |
def _make_skel_func(code, cell_count, base_globals=None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ closure = ( tuple(_make_empty_cell() for _ in range(cell_count)) if cell_count >= 0 else None ) return types.FunctionType(code, base_globals, None, None, closure)
Example #5
Source File: cloudpickle.py From spark-cluster-deployment with Apache License 2.0 | 5 votes |
def save_dict(self, obj): """hack fix If the dict is a global, deal with it in a special way """ #print 'saving', obj if obj is __builtins__: self.save_reduce(_get_module_builtins, (), obj=obj) else: pickle.Pickler.save_dict(self, obj)
Example #6
Source File: cloudpickle.py From pywren with Apache License 2.0 | 5 votes |
def _make_skel_func(code, cell_count, base_globals=None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ closure = ( tuple(_make_empty_cell() for _ in range(cell_count)) if cell_count >= 0 else None ) return types.FunctionType(code, base_globals, None, None, closure)
Example #7
Source File: cloudpickle.py From eggroll with Apache License 2.0 | 5 votes |
def _make_skel_func(code, cell_count, base_globals=None): """ Creates a skeleton function object that contains just the provided code and the correct number of cells in func_closure. All other func attributes (e.g. func_globals) are empty. """ if base_globals is None: base_globals = {} base_globals['__builtins__'] = __builtins__ closure = ( tuple(_make_empty_cell() for _ in range(cell_count)) if cell_count >= 0 else None ) return types.FunctionType(code, base_globals, None, None, closure)