[Tutor] problem with unpickling an object

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


-----BEGIN PGP SIGNED MESSAGE-----
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEhDw0tXlIMrUVVksRApzBAJ427uRcMuQk6TgqGfWGZu8GjlZWBgCbBTBP
83oVZ9NNswfGrzk58Bat57k=
=J5gs
-----END PGP SIGNATURE-----


More information about the Tutor mailing list