当前位置: 首页>>代码示例>>Python>>正文


Python pickle.__builtins__方法代码示例

本文整理汇总了Python中pickle.__builtins__方法的典型用法代码示例。如果您正苦于以下问题:Python pickle.__builtins__方法的具体用法?Python pickle.__builtins__怎么用?Python pickle.__builtins__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pickle的用法示例。


在下文中一共展示了pickle.__builtins__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _make_skel_func

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import __builtins__ [as 别名]
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 
开发者ID:adobe-research,项目名称:spark-cluster-deployment,代码行数:24,代码来源:cloudpickle.py

示例2: _make_skel_func

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import __builtins__ [as 别名]
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) 
开发者ID:FederatedAI,项目名称:FATE,代码行数:17,代码来源:cloudpickle.py

示例3: save_dict

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import __builtins__ [as 别名]
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) 
开发者ID:adobe-research,项目名称:spark-cluster-deployment,代码行数:11,代码来源:cloudpickle.py

示例4: _make_skel_func

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import __builtins__ [as 别名]
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) 
开发者ID:WeBankFinTech,项目名称:eggroll,代码行数:17,代码来源:cloudpickle.py


注:本文中的pickle.__builtins__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。