pickle/unpickle class which has changed
Peter Otten
__peter__ at web.de
Wed Mar 7 03:04:31 EST 2012
Gelonida N wrote:
> Is there anyhing like a built in signature which would help to detect,
> that one tries to unpickle an object whose byte code has changed?
No. The only thing that is stored is the "protocol", the format used to
store the data.
> The idea is to distinguish old and new pickled data and start some
> 'migration code' fi required
> The only thing, that I thought about so far was adding an explicit
> version number to each class in order to detect such situations.
If you know in advance that your class will undergo significant changes you
may also consider storing more stable data in a file format that can easily
be modified, e. g. json.
More information about the Python-list
mailing list