pickle != cPickle

Robin Becker robin at jessikat.demon.co.uk
Sat Jan 1 12:07:22 EST 2000


I notice that cPickle and pickle sometimes give different results. This worries me as I thought
these two were now strictly comparable. What sort of things can cause this? It appears they
still give the same answer on unpickle.

eg
>>> dp=pickle.dumps(d['LNUX'])
>>> dc=cPickle.dumps(d['LNUX'])
>>> len(dp),len(dc)
(1502, 1525)
>>> dc
"(i__main__\012_YahooData\012p1\012(dp2\012S'Low'\012p3\012(lp4\012I233\012aI215\012......
>>> dp
"(i__main__\012_YahooData\012p0\012(dp1\012S'Low'\012p2\012(lp3\012I233\012aI215\012......
>>> np=pickle.loads(dp)
>>> nc=pickle.loads(dc)
>>> dir(np)==dir(nc)
1
>>> for s in dir(np):
...     print s, getattr(np,s)==getattr(nc,s)
... 
Close 1
High 1
Low 1
Open 1
Volume 1
date 1
finish 1
start 1
ticker 1
>>> 
-- 
Robin Becker



More information about the Python-list mailing list