[Tutor] problem with unpickling an object

Yi Qiang yi at yiqiang.net
Mon Jun 5 16:14:12 CEST 2006

Hash: SHA1

Kent Johnson wrote, On 06/05/2006 03:12 AM:
>  From a quick read of the docs, it looks like you should set the 
> unpickler's find_global attribute to a function you define. This 
> function can first attempt to load the desired class (see 
> pickle.find_class() for an example). If the load fails, then return a 
> placeholder class that you define.
> This won't give exactly the result you ask for, instead of None in the 
> dictionary you will have instances of the placeholder. You could then 
> post-process the dict to change the placeholder instances to None if you 
> like.

Interesting, so if I used this method I won't be able to use cPickle
anymore.  The documentation just says that cPickle is "faster", but can
anyone quantify how much speed I am losing if I move to the regular
pickle module?

- --
Yi Qiang (yi at yiqiang.net)
Web: http://www.yiqiang.net
Tel: (206) 661-8469
PGP: 0xB515564B
Version: GnuPG v1.4.2.2 (GNU/Linux)


More information about the Tutor mailing list