[Python-Dev] [ 654866 ] pickle and cPickle not equivalent

Jim Fulton jim@zope.com
Wed, 18 Dec 2002 13:36:49 -0500


Guido van Rossum wrote:
>>Not sure I completely agree, but I'm not trying to pick a fight, either. 
>>I just wish the following bit from the docs was true, whether pickle or 
>>cPickle were used, whether the object was first pickled inside some 
>>container and later pickled on its own, whether the instance was a 
>>new-style class or an old-style class, etc.:
>>
>><quote>
>>It is possible to make multiple calls to the dump() method of the same 
>>Pickler instance. These must then be matched to the same number of 
>>calls to the load() method of the corresponding Unpickler instance. If 
>>the same object is pickled by multiple dump() calls, the load() will 
>>all yield references to the same object.
>></quote>
>>
>>The fact that I'm no longer sure whether I'll get back a reference to a 
>>previously pickle instance or not calls into question whether pickling 
>>can be the foundation for a reliable Python persistence system. I can't 
>>help but express my disappointment. Was I really expecting too much 
>>from pickle/cPickle?
>>
> 
> Probably.  I have to admit that the "multiple calls to dump()" feature
> is not often used; maybe it should be deprecated so we don't make
> promises we can't fulfill.  E.g. Zope never uses this.

Zope does use this.

Zope doesn't pickle the same object multiple times in the separate
load calls, however.  This may be a matter of luck.

I think Patrick raises a reasonable issue, although it would require
slowing things down a bit to fix it.

Patrick, why do you feel you need this for a reliable persistence
system? ZODB doesn't need this.

Jim


-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org