http://oldj.net/article/python-pickle/
i like use jsonpy than py2.6 embedded json lib,beacause it is more friendly for unicode
reference
http://oldj.net/article/python-pickle/
some write style i record here:
import jsonpy
import os.path
import cPickle as pickle
import time
if os.path.exists("cache.pickle"):
it=time.time()
cache= pickle.load(open("cache.pickle", "rb"))
print "cost time:%ss"%(time.time()-it)
print "直接从cache.pickle载入"
print len(cache)
if os.path.exists("cache.txt") and (not os.path.exists("cache.pickle")):
print "从cache.txt载入"
cc=0
itit=time.time()
for line in open("cache.txt","r").readlines():
cc+=1
print cc
k,v=line.strip().split("||||||")
#print type(jsonpy.read(v))
cache[k]=jsonpy.read(v)
print "载入缓存成功"
print "cost time:%ss"%(time.time()-itit)
print len(cache)
from lib import filehelper
if filehelper.hasfile("cache.pickle"):
filehlper.delfile("cache.pickle")
print "删除先前的cache.pickle"
pickle.dump(cache, open("cache.pickle", "wb"), True)
print "导出成cache.pickle"
分享到:
相关推荐
5,000,000 轮转储/装载消耗的时间: fserial.dumps: 1.581582marshal.dumps: 5.548474cPickle.dumps: 5.602932simplejson.loads: #approximate 10x slower than cPickle/marshalfserial.loads:
that it requires all the right-hand sides to be stored and manipulated at the same time, and (ii) that when the inverse matrix is not desired, Gauss-Jordan is three times slower than the best ...
快速验签算法,Verification of ECDSA signatures is considerably slower than generation of ECDSA signatures. This paper describes a method that can be used to accelerate verification of ECDSA signatures...
Socket通信,通过异步,解决粘包问题
Why Python is Slow: ...# Why Python is Slow Python is slower than Fortran and C for a variety of reasons # Python meta-hacking: Don't take my word for it # Just for fun: a few "never use these" hacks
FFvp9 is somewhat slower than ffvp8, and somewhat faster than ffh264 decoding speed (for files encoded to matching SSIM scores). Multi-threading performance in libvpx is deplorable, it gains ...
序列对齐 Compare a protein sequence to a protein sequence database or a DNA sequence to a DNA sequence database ...slower than FASTA3, but is more sensitive for full-length protein sequence comparison.
A Slower Speed of Light 游戏制作者的初心类似互动教学,改变相对论在公众心中的玄学地位。 A Slower Speed Of Light是一款第一人称游戏原型,玩家在 3D 空间中导航,同时拾取逐渐降低光速的球体。定制的、开源的...
slower than the clean code (because the clean code has become faster, not because the uglier code has become slower). This Efficiency Guide cannot really learn you how to write efficient code. It can ...
On foot, you travel slower than by car, and you may not want to gather location data as often. If you're standing still, why track location at all - it's just a waste of power. If you're on a photo ...
快一点 受和启发,此命令行工具使您的Ruby运行得更...app/models/post.rb:57 Array#select.first is slower than Array#detect. app/models/post.rb:61 Array#select.first is slower than Array#detect. db/seeds/citi
C ++语言在此存储库中,我们将学习C ++概念CPP中的缓冲区临时存储区称为缓冲...关键点 1.) endl is slower than "\n" 2.) To pass 2 -d array in Function there is 3 special way one is - void func(int **arr,int N)
开源项目-pzduniak-argon2.zip,libargon2 converted from C to Go. Only around 10 times slower than the bindings!
Learn how TCP affects the performance of HTTP Understand why mobile networks are slower than wired networks Use best practices to address performance bottlenecks in HTTP Discover how HTTP 2.0 (based ...
Learn how TCP affects the performance of HTTP Understand why mobile networks are slower than wired networks Use best practices to address performance bottlenecks in HTTP Discover how HTTP 2.0 (based ...
Although slower than the mA710 (200ns response time vs 40ns), the devices are also much less prone to spurious oscillations. The LM111 series has the same pin configuration as the mA710 series. ...
Sending data across a network is multiple orders of magnitude slower than making a local method call. Designing a widely distributed solution the same way you would approach a single application ...
A decent rule of thumb is to not inline a function if it is more than 10 lines long. Beware of destructors, which are often longer than they appear because of implicit member- and base-destructor ...
Given that processors can be orders of magnitudes faster than the hardware they talk to, it is not ideal for the kernel to issue a request and wait for a response from the significantly slower ...
关于java学习的书 大学内部资料 This is the fourth edition of a book I started writing in 1999, when I was teaching ... In other words, they would read it seven times slower than I wrote it.