Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35655
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: pickle module doens't work |
| Date | 2012-12-27 16:19 -0500 |
| References | <ee10f0f7-7713-4879-82a1-ec5804767af6@googlegroups.com> <mailman.1339.1356607732.29569.python-list@python.org> <f6ea95c2-2448-4f93-8aa4-e4e2aeb731ba@googlegroups.com> <50DC4043.3060606@davea.name> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1370.1356643212.29569.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 02:46 -0800
Re: pickle module doens't work Peter Otten <__peter__@web.de> - 2012-12-27 12:29 +0100
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 04:05 -0800
Re: pickle module doens't work Dave Angel <d@davea.name> - 2012-12-27 07:34 -0500
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 05:16 -0800
Re: pickle module doens't work Chris Angelico <rosuav@gmail.com> - 2012-12-28 00:20 +1100
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 05:16 -0800
Re: pickle module doens't work Tim Roberts <timr@probo.com> - 2012-12-28 21:41 -0800
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2013-01-01 06:33 -0800
Re: pickle module doens't work Tim Roberts <timr@probo.com> - 2013-01-01 11:14 -0800
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2013-01-02 06:08 -0800
Re: pickle module doens't work Terry Reedy <tjreedy@udel.edu> - 2012-12-27 16:19 -0500
Re: pickle module doens't work Omer Korat <animus.partum.universum@gmail.com> - 2012-12-27 04:05 -0800
csiph-web