[issue8738] cPickle dumps(tuple) != dumps(loads(dumps(tuple)))

2010-07-14 Thread Alexander Belopolsky
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 =

[issue8738] cPickle dumps(tuple) != dumps(loads(dumps(tuple)))

2010-07-14 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: OK, the 2.7 behavior is explainable and correct. cPickle checks the reference count and does not generate PUT for objects that don't have references: from pickletools import dis from cPickle import dumps

[issue8738] cPickle dumps(tuple) != dumps(loads(dumps(tuple)))

2010-07-14 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I am speculating here while Alexandre probably knows the answer. The skip PUT on unreferenced objects optimization was probably removed because doing so makes _pickle module behave more like pickle and because

[issue8738] cPickle dumps(tuple) != dumps(loads(dumps(tuple)))

2010-05-17 Thread Alberto Planas Domínguez
New submission from Alberto Planas Domínguez apla...@gmail.com: Sometimes, when I use cPickle to serialize tuples of strings, I get different dumps() result for the same tuple: import cPickle t = ('s', 'JOHN') s1 = cPickle.dumps(t) s2 = cPickle.dumps(cPickle.loads(cPickle.dumps(t))) assert s1

[issue8738] cPickle dumps(tuple) != dumps(loads(dumps(tuple)))

2010-05-17 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I don't think you can expect serialized results to always be equal. It can depend on specifics of the internal algorithm, such as optimizations or dict iteration order. -- nosy: +alexandre.vassalotti, pitrou priority: normal - low