Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:
There seems to be a bug somewhere in 2.x cPickle. Here is a somewhat simpler way to demonstrate the bug: the following code from pickletools import dis import cPickle t = 1L, # use long for easy 3.x comparison s1 = cPickle.dumps(t) s2 = cPickle.dumps(cPickle.loads(s1)) print(s1 == s2) dis(s1) dis(s2) prints False 0: ( MARK 1: L LONG 1L 5: t TUPLE (MARK at 0) 6: p PUT 1 9: . STOP highest protocol among opcodes = 0 0: ( MARK 1: L LONG 1L 5: t TUPLE (MARK at 0) 6: . STOP highest protocol among opcodes = 0 The difference is probably immaterial because nothing in the pickle uses the tuple again and PUT is redundant, but the difference does not show up when python pickle module is used instead of cPickle and is not present in py3k. The comparable py3k code: from pickletools import dis import pickle t = 1, s1 = pickle.dumps(t, 0) s2 = pickle.dumps(pickle.loads(s1), 0) print(s1 == s2) dis(s1) dis(s2) produces True 0: ( MARK 1: L LONG 1 5: t TUPLE (MARK at 0) 6: p PUT 0 9: . STOP highest protocol among opcodes = 0 0: ( MARK 1: L LONG 1 5: t TUPLE (MARK at 0) 6: p PUT 0 9: . STOP highest protocol among opcodes = 0 Most likely the bug is benign and not worth fixing, but I would like to figure out what's going on and what changed in 3.x. ---------- assignee: -> belopolsky nosy: +belopolsky versions: -Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8738> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com