Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52807 > unrolled thread
| Started by | Fredrik Tolf <fredrik@dolda2000.com> |
|---|---|
| First post | 2013-08-22 05:05 +0200 |
| Last post | 2013-08-22 05:05 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
RE: Unpickling data with classes from dynamic modules Fredrik Tolf <fredrik@dolda2000.com> - 2013-08-22 05:05 +0200
| From | Fredrik Tolf <fredrik@dolda2000.com> |
|---|---|
| Date | 2013-08-22 05:05 +0200 |
| Subject | RE: Unpickling data with classes from dynamic modules |
| Message-ID | <mailman.116.1377140706.19984.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web