Alternatives to pickle/class nesting
Emile van Sebille
emile at fenx.com
Fri Jul 2 08:29:25 EDT 1999
Good morning,
Unlike Gerrit's problem with seemingly large amounts of space being
consumed for storage, I cpickled my object and was impressed that only
81 bytes were used. Of course, the entire object didn't get pickled.
In browsing dejanews, I found a post by Guido saying that nested class
structures, being rare, are not supported by pickle. Being new to this,
I didn't anticipate the pending pickle problem, and now need to either
restructure the classes into one pickle-friendly object with the same
functionality, or look at alternatives for swizzling these objects?
Essentially, my class instances consist of a few variables, and two
dictionaries of string keys and UserList values modified for write-only
stack-like behavior. If I do restructure the classes, by retaining the
same/similar structure without external class instances in the
structure, is it likely pickle will deal with it properly?
Can __getinitargs__, __getstate__ and __setstate__ be used to correct
this?
I have a debug display routine that dumps the contents of these
instances. Any way to use this routine to create a local __dump__ /
__load__ pair. Dumping I think I get, but are there traps in the
loading?
Any suggestions?
--
Emile van Sebille
emile at fenx.com
-------------------
More information about the Python-list
mailing list