471,325 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Discovery of unpickleables in class heirarchies.

I've a need to pickle arbitrary class hierarchies, which, luckily, can
be made to conform to the pickle protocol. At the moment, however, I'm
having a rather hard time discovering which classes in a heirarchy
cannot be pickles. For instance, say class A has class B in it's
__dict__ and let class B have a file handler in its __dict__. When I
call cPickle.dumps(A) UnpickleableError will be raised when B's file
handler is reached, but the error will only report being unable to
pickle the file handler, saying nothing of B or A. I wouldn't expect
cPickle to do that, but I do need to know somehow that class B has
failed to pickle properly.

To that end I've quickly hacked out a class that, ideally, will take
an object that I'm attempting to pickle and, if the pickling does not
succeed, recurse through the class heirarchy collecting information on
which objects were not pickled. It is here: http://deadbeefbabe.org/paste/5218
The output, for the above example would be:

<type 'A'>
<type 'B'>
<type 'file'>

However, it seems to be taking a rather long time. Perhaps my class
heirarchies are too deep, or my recursion is flawed. Can anyone see a
bug in my code, or have a better way of discovering this information
altogether?

Jun 22 '07 #1
0 858

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Anurag | last post: by
6 posts views Thread by jason | last post: by
3 posts views Thread by Tim Mavers | last post: by
reply views Thread by serge calderara | last post: by
6 posts views Thread by razael1 | last post: by
4 posts views Thread by ddtl | last post: by
7 posts views Thread by Chris Mullins | last post: by
reply views Thread by news.microsoft.com | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.