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

Guido van Rossum guido@python.org
Wed, 18 Dec 2002 11:00:42 -0500


> 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.

> In any case, I've submitted the following documentation bug report on 
> SF:
> 
>   [ 655802 ] cPickle not always same as pickle

You could help by submitting a doc patch that satisfies your
desire for more clear and honest docs.  If you don't know LaTeX, that
doesn't matter; just pretend it's plain text and somebody will fix up
the markup, as long as you provide the new words.

--Guido van Rossum (home page: http://www.python.org/~guido/)