On 12/27/2012 7:34 AM, Dave Angel wrote:

Perhaps you'd rather see it in the Python docs.

http://docs.python.org/2/library/pickle.html
http://docs.python.org/3.3/library/pickle.html

pickle <http://docs.python.org/2/library/pickle.html#module-pickle>can
save and restore class instances transparently, however the class
definition must be importable and live in the same module as when the
object was stored.
and
Similarly, when class instances are pickled, their class’s code and data
are not pickled along with them. Only the instance data are pickled.
This is done on purpose, so you can fix bugs in a class or add methods
to the class and still load objects that were created with an earlier
version of the class.

I should point out the the above was probably written before the (partial) unification of types and classes in 2.2 (completed in 3.3). So 'class' is referring to 'Python-coded class' and 'code' is referring to '(compiled) Python code', and not machine code. Now, everything that pickle pickles is a 'class instance' and class code can be compiled from either Python or the interpreter's system language (C, Java, C#, others, or even Python itself).

--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to