Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52807
| Date | 2013-08-22 05:05 +0200 |
|---|---|
| From | Fredrik Tolf <fredrik@dolda2000.com> |
| Subject | RE: Unpickling data with classes from dynamic modules |
| References | <alpine.DEB.2.10.1308211732440.18360@shack.dolda2000.com> <5B80DD153D7D744689F57F4FB69AF4741867F701@SCACMX008.exchad.jpmchase.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.116.1377140706.19984.python-list@python.org> (permalink) |
On Wed, 21 Aug 2013, Prasad, Ramit wrote: > Fredrik Tolf wrote: >> [...] >> I considered trying to create subclasses of the pickler and unpickler that >> pickle a reference to a module loader and data for the particular module >> along with a class that comes from such a module, by overriding >> Pickler.save_global and Unpickler.load_global. Unfortunately, however, >> those functions aren't part of the public interface and can't be >> overridden when the C-pickle module is used instead (which, obviously, is >> what normally happens). >> [...] > > I believe rather than subclassing the pickler, you are expected to > change the behavior from within the class via __getstate__ and __setstate__. Well, that clearly wouldn't work, since that still assumes the module can be found. > Maybe all you need to add is implementation for obj.__reduce__ That would certainly work, and I guess I could perhaps use it as a work-around, but that would mean I'd have to mark every single such class as such in some way or another. What I'm looking for is a solution that could make them picklable transparently, just like normal. -- Fredrik Tolf
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Unpickling data with classes from dynamic modules Fredrik Tolf <fredrik@dolda2000.com> - 2013-08-22 05:05 +0200
csiph-web