示例#1
0
def dump_items(filename, items):
    """Pickle items to disk.

    Doesn't handle exceptions.
    """

    dirname = os.path.dirname(filename)
    mkdir(dirname)

    with atomic_save(filename, "wb") as fileobj:
        # While protocol 2 is usually faster it uses __setitem__
        # for unpickle and we override it to clear the sort cache.
        # This roundtrip makes it much slower, so we use protocol 1
        # unpickle numbers (py2.7):
        #   2: 0.66s / 2 + __set_item__: 1.18s / 1 + __set_item__: 0.72s
        # see: http://bugs.python.org/issue826897
        pickle.dump(items, fileobj, 1)
示例#2
0
def dump_items(filename, items):
    """Pickle items to disk.

    Doesn't handle exceptions.
    """

    dirname = os.path.dirname(filename)
    mkdir(dirname)

    with atomic_save(filename, "wb") as fileobj:
        # While protocol 2 is usually faster it uses __setitem__
        # for unpickle and we override it to clear the sort cache.
        # This roundtrip makes it much slower, so we use protocol 1
        # unpickle numbers (py2.7):
        #   2: 0.66s / 2 + __set_item__: 1.18s / 1 + __set_item__: 0.72s
        # see: http://bugs.python.org/issue826897
        pickle.dump(items, fileobj, 1)
示例#3
0
 def write(klass):
     feeds = [row[0] for row in klass.__feeds]
     with open(FEEDS, "wb") as f:
         pickle.dump(feeds, f, pickle.HIGHEST_PROTOCOL)
示例#4
0
 def write(klass):
     feeds = [row[0] for row in klass.__feeds]
     with open(FEEDS, "wb") as f:
         pickle.dump(feeds, f, pickle.HIGHEST_PROTOCOL)