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 >>> dis(dumps(tuple([1]))) 0: ( MARK 1: I INT 1 4: t TUPLE (MARK at 0) 5: . STOP highest protocol among opcodes = 0 >>> t = 1, >>> dis(dumps(t)) 0: ( MARK 1: I INT 1 4: t TUPLE (MARK at 0) 5: p PUT 1 8: . STOP highest protocol among opcodes = 0 This optimization is not available from python, of course so pickle.py behaves differently. The remaining question is why this optimization was removed from 3.x. ---------- versions: +Python 3.2 -Python 2.7 _______________________________________ 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