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


Python pickle.INST属性代码示例

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


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

示例1: save_inst

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INST [as 别名]
def save_inst(self, obj):
        """Inner logic to save instance. Based off pickle.save_inst"""
        cls = obj.__class__

        # Try the dispatch table (pickle module doesn't do it)
        f = self.dispatch.get(cls)
        if f:
            f(self, obj)  # Call unbound method with explicit self
            return

        memo = self.memo
        write = self.write
        save = self.save

        if hasattr(obj, '__getinitargs__'):
            args = obj.__getinitargs__()
            len(args)  # XXX Assert it's a sequence
            pickle._keep_alive(args, memo)
        else:
            args = ()

        write(pickle.MARK)

        if self.bin:
            save(cls)
            for arg in args:
                save(arg)
            write(pickle.OBJ)
        else:
            for arg in args:
                save(arg)
            write(pickle.INST + cls.__module__ + '\n' + cls.__name__ + '\n')

        self.memoize(obj)

        try:
            getstate = obj.__getstate__
        except AttributeError:
            stuff = obj.__dict__
        else:
            stuff = getstate()
            pickle._keep_alive(stuff, memo)
        save(stuff)
        write(pickle.BUILD) 
开发者ID:pywren,项目名称:pywren-ibm-cloud,代码行数:46,代码来源:cloudpickle.py

示例2: save_inst_logic

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INST [as 别名]
def save_inst_logic(self, obj):
        """Inner logic to save instance. Based off pickle.save_inst
        Supports __transient__"""
        cls = obj.__class__

        memo  = self.memo
        write = self.write
        save  = self.save

        if hasattr(obj, '__getinitargs__'):
            args = obj.__getinitargs__()
            len(args) # XXX Assert it's a sequence
            pickle._keep_alive(args, memo)
        else:
            args = ()

        write(pickle.MARK)

        if self.bin:
            save(cls)
            for arg in args:
                save(arg)
            write(pickle.OBJ)
        else:
            for arg in args:
                save(arg)
            write(pickle.INST + cls.__module__ + '\n' + cls.__name__ + '\n')

        self.memoize(obj)

        try:
            getstate = obj.__getstate__
        except AttributeError:
            stuff = obj.__dict__
            #remove items if transient
            if hasattr(obj, '__transient__'):
                transient = obj.__transient__
                stuff = stuff.copy()
                for k in list(stuff.keys()):
                    if k in transient:
                        del stuff[k]
        else:
            stuff = getstate()
            pickle._keep_alive(stuff, memo)
        save(stuff)
        write(pickle.BUILD) 
开发者ID:adobe-research,项目名称:spark-cluster-deployment,代码行数:48,代码来源:cloudpickle.py

示例3: save_inst

# 需要导入模块: import pickle [as 别名]
# 或者: from pickle import INST [as 别名]
def save_inst(self, obj):
    """Inner logic to save instance. Based off pickle.save_inst"""
    cls = obj.__class__

    # Try the dispatch table (pickle module doesn't do it)
    f = self.dispatch.get(cls)
    if f:
      f(self, obj)  # Call unbound method with explicit self
      return

    memo = self.memo
    write = self.write
    save = self.save

    if hasattr(obj, '__getinitargs__'):
      args = obj.__getinitargs__()
      len(args)  # XXX Assert it's a sequence
      pickle._keep_alive(args, memo)
    else:
      args = ()

    write(pickle.MARK)

    if self.bin:
      save(cls)
      for arg in args:
        save(arg)
      write(pickle.OBJ)
    else:
      for arg in args:
        save(arg)
      write(pickle.INST + cls.__module__ + '\n' + cls.__name__ + '\n')

    self.memoize(obj)

    try:
      getstate = obj.__getstate__
    except AttributeError:
      stuff = obj.__dict__
    else:
      stuff = getstate()
      pickle._keep_alive(stuff, memo)
    save(stuff)
    write(pickle.BUILD) 
开发者ID:WeBankFinTech,项目名称:eggroll,代码行数:46,代码来源:cloudpickle.py


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