python类Pickler()的实例源码

bm_pickle.py 文件源码 项目:performance 作者: python 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def is_module_accelerated(module):
    return getattr(pickle.Pickler, '__module__', '<jython>') == 'pickle'
gencache.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _SaveDicts():
    if is_readonly:
        raise RuntimeError("Trying to write to a readonly gencache ('%s')!" \
                            % win32com.__gen_path__)
    f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
    try:
        p = pickle.Pickler(f)
        p.dump(pickleVersion)
        p.dump(clsidToTypelib)
    finally:
        f.close()
__init__.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, servers=None, debug=0,
               pickleProtocol=cPickle.HIGHEST_PROTOCOL,
               pickler=cPickle.Pickler,
               unpickler=cPickle.Unpickler,
               pload=None,
               pid=None,
               make_sync_call=None,
               _app_id=None):
    """Create a new Client object.

    No parameters are required.

    Arguments:
      servers: Ignored; only for compatibility.
      debug: Ignored; only for compatibility.
      pickleProtocol: Pickle protocol to use for pickling the object.
      pickler: pickle.Pickler sub-class to use for pickling.
      unpickler: pickle.Unpickler sub-class to use for unpickling.
      pload: Callable to use for retrieving objects by persistent id.
      pid: Callable to use for determine the persistent id for objects, if any.
      make_sync_call: Ignored; only for compatibility with an earlier version.
    """





    self._pickler_factory = pickler
    self._unpickler_factory = unpickler
    self._pickle_protocol = pickleProtocol
    self._persistent_id = pid
    self._persistent_load = pload
    self._app_id = _app_id
    self._cas_ids = {}
test_cpickle.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        f = self.output()
        try:
            p = cPickle.Pickler(f, proto)
            p.dump(arg)
            f.seek(0)
            return f.read()
        finally:
            self.close(f)
test_cpickle.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        p = cPickle.Pickler(proto)
        p.dump(arg)
        return p.getvalue()
test_cpickle.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        f = self.output()
        try:
            p = cPickle.Pickler(f, proto)
            p.fast = 1
            p.dump(arg)
            f.seek(0)
            return f.read()
        finally:
            self.close(f)
shelve.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if self.writeback:
            self.cache[key] = value
        f = StringIO()
        p = Pickler(f, self._protocol)
        p.dump(value)
        self.dict[key] = f.getvalue()
agl.py 文件源码 项目:autoxd 作者: nessessary 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def serial(result, fname = "temp.bin"):
        if charade.detect(fname)['encoding'] == 'utf-8':
            fname = convert(fname)

        root_dir = os.path.dirname(__file__)
        fname = root_dir + "\\" +fname            
        f = open(fname,"wb")        
        p = cPickle.Pickler(f)
        p.clear_memo()
        p.fast = True
        p.dump(result)
        f.close()
test_cpickle.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        f = self.output()
        try:
            p = cPickle.Pickler(f, proto)
            p.dump(arg)
            f.seek(0)
            return f.read()
        finally:
            self.close(f)
test_cpickle.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        p = cPickle.Pickler(proto)
        p.dump(arg)
        return p.getvalue()
test_cpickle.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def dumps(self, arg, proto=0):
        f = self.output()
        try:
            p = cPickle.Pickler(f, proto)
            p.fast = 1
            p.dump(arg)
            f.seek(0)
            return f.read()
        finally:
            self.close(f)
shelve.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if self.writeback:
            self.cache[key] = value
        f = StringIO()
        p = Pickler(f, self._protocol)
        p.dump(value)
        self.dict[key] = f.getvalue()
datastore_file_stub.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __WritePickled(self, obj, filename):
    """Pickles the object and writes it to the given file.
    """
    if not filename or filename == '/dev/null' or not obj:
      return


    descriptor, tmp_filename = tempfile.mkstemp(dir=os.path.dirname(filename))
    tmpfile = os.fdopen(descriptor, 'wb')





    pickler = pickle.Pickler(tmpfile, protocol=1)
    pickler.fast = True
    pickler.dump(obj)

    tmpfile.close()

    self.__file_lock.acquire()
    try:
      try:

        os.rename(tmp_filename, filename)
      except OSError:

        try:
          os.remove(filename)
        except:
          pass
        os.rename(tmp_filename, filename)
    finally:
      self.__file_lock.release()
__init__.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, servers=None, debug=0,
               pickleProtocol=cPickle.HIGHEST_PROTOCOL,
               pickler=cPickle.Pickler,
               unpickler=cPickle.Unpickler,
               pload=None,
               pid=None,
               make_sync_call=None,
               _app_id=None):
    """Create a new Client object.

    No parameters are required.

    Arguments:
      servers: Ignored; only for compatibility.
      debug: Ignored; only for compatibility.
      pickleProtocol: Pickle protocol to use for pickling the object.
      pickler: pickle.Pickler sub-class to use for pickling.
      unpickler: pickle.Unpickler sub-class to use for unpickling.
      pload: Callable to use for retrieving objects by persistent id.
      pid: Callable to use for determine the persistent id for objects, if any.
      make_sync_call: Ignored; only for compatibility with an earlier version.
    """





    self._pickler_factory = pickler
    self._unpickler_factory = unpickler
    self._pickle_protocol = pickleProtocol
    self._persistent_id = pid
    self._persistent_load = pload
    self._app_id = _app_id
    self._cas_ids = {}
shelve.py 文件源码 项目:empyrion-python-api 作者: huhlig 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        if self.writeback:
            self.cache[key] = value
        f = StringIO()
        p = Pickler(f, self._protocol)
        p.dump(value)
        self.dict[key] = f.getvalue()
redis.py 文件源码 项目:dissonance 作者: jhgg 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __setitem__(self, key, value):
        with self._cache_write_lock:
            self._cache[key] = value

        f = StringIO()
        p = Pickler(f, self._protocol)
        p.dump(value)

        self._storage.redis.hset(self._hash_key, key, f.getvalue())
redis.py 文件源码 项目:dissonance 作者: jhgg 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def sync(self):
        if not self._cache:
            return

        with self._cache_write_lock, self._storage.redis.pipeline() as pipeline:
            for key, entry in self._cache.items():
                f = StringIO()
                p = Pickler(f, self._protocol)
                p.dump(entry)
                pipeline.hset(self._hash_key, key, f.getvalue())

            pipeline.execute()
            self._cache.clear()
__init__.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, servers=None, debug=0,
               pickleProtocol=cPickle.HIGHEST_PROTOCOL,
               pickler=cPickle.Pickler,
               unpickler=cPickle.Unpickler,
               pload=None,
               pid=None,
               make_sync_call=None,
               _app_id=None):
    """Create a new Client object.

    No parameters are required.

    Arguments:
      servers: Ignored; only for compatibility.
      debug: Ignored; only for compatibility.
      pickleProtocol: Pickle protocol to use for pickling the object.
      pickler: pickle.Pickler sub-class to use for pickling.
      unpickler: pickle.Unpickler sub-class to use for unpickling.
      pload: Callable to use for retrieving objects by persistent id.
      pid: Callable to use for determine the persistent id for objects, if any.
      make_sync_call: Ignored; only for compatibility with an earlier version.
    """





    self._pickler_factory = pickler
    self._unpickler_factory = unpickler
    self._pickle_protocol = pickleProtocol
    self._persistent_id = pid
    self._persistent_load = pload
    self._app_id = _app_id
    self._cas_ids = {}
store.py 文件源码 项目:Meiji 作者: GiovanniBalestrieri 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def dumps(self, obj, protocol=None, bin=None):
        src = BytesIO()
        p = Pickler(src)
        p.persistent_id = self._get_ids
        p.dump(obj)
        return src.getvalue()
store.py 文件源码 项目:prophet 作者: MKLab-ITI 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def dumps(self, obj, protocol=None, bin=None):
        src = BytesIO()
        p = Pickler(src)
        p.persistent_id = self._get_ids
        p.dump(obj)
        return src.getvalue()


问题


面经


文章

微信
公众号

扫码关注公众号