Mailing List Archive

Alternatives to pickle/class nesting
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@fenx.com
-------------------
Alternatives to pickle/class nesting [ In reply to ]
From: "Emile van Sebille" <emile@fenx.com>

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@fenx.com
-------------------
Alternatives to pickle/class nesting [ In reply to ]
From: "Emile van Sebille" <emile@fenx.com>

Well, I've spent the last couple of hours trying to piece a small sample
together that illustrates my problem. Good news... No success! ;-)
This probably means I've got some squirrelly code in the application
somewhere, or that I can restructure towards my sample and get things
going.

Comments-still-welcome-but-I'm-out-of-my-pickle-ly yr's

--

Emile van Sebille
emile@fenx.com
-------------------
Alternatives to pickle/class nesting [ In reply to ]
Well, I've spent the last couple of hours trying to piece a small sample
together that illustrates my problem. Good news... No success! ;-)
This probably means I've got some squirrelly code in the application
somewhere, or that I can restructure towards my sample and get things
going.

Comments-still-welcome-but-I'm-out-of-my-pickle-ly yr's

--

Emile van Sebille
emile@fenx.com
-------------------