[Python-ideas] Adding a safe alternative to pickle in the standard library

Steven D'Aprano steve at pearwood.info
Fri Feb 22 07:55:12 CET 2013


On 22/02/13 10:39, Bruce Leban wrote:

> There's another problem - pickling is not guaranteed to work across Python
> versions.

I think you are confusing pickle with marshal.

Obviously you cannot guarantee unpickling in older versions of Python,
e.g. I can't unpickle a Python 2.7 set in Python 2.1, since sets didn't
exist back then. Or a pickle created using version N of the protocol
requires a Python version recent enough to understand version N, e.g.
protocol 3 exists only in Python 3.x.

But going forward should not be a problem, and the pickle documentation
promises backwards-compatibility. Actually I believe that *forward*
compatibility is a better description, but either way, the compatibility
is guaranteed:

Python version X will be able to unpickle anything pickled by an older
version of Python; furthermore, anything pickled by version X will be
able to be unpickled by future versions.

(Modulo removal of the pickled classes, etc.)



-- 
Steven



More information about the Python-ideas mailing list