Pickle: several class instance objects in one file?

Dominique.Holzwarth at ch.delarue.com Dominique.Holzwarth at ch.delarue.com
Thu Mar 27 13:28:25 CET 2008

Hi everyone

I've never used the module 'pickle' so far, thus I've got some questions about how to use it:

Lets say I have instances of class A and class B:

a = A()
b = B()

Is it possible to pickle both of these instances to the same pkl-file or will that have any bad impact for unpickle (i.e. the instance are 'mixed' or 'destroyed')? Or should I rather use a seperate file for every class instance I want to pickle?

Another very basic question about pickling class instances:

To store the value of attributes of an instance is it enough for the pickling-algorithm to use the __dict__ or do I have to implement the _setstate_ and _getstate_ function? I didn't really get the meaning of those while reading the python user manual...

Thanks in advance


More information about the Python-list mailing list