getstate, setstate and pickle

Emile van Sebille emile at
Thu Jun 24 20:28:17 EDT 1999

I've identified my problem. uses map(id,..) as part of its
test routine.  I tried to use the same to test.  map(id,...) (which
likes sequences) doesn't work on my class instances.

The script below illustrates that dumps(r) ==dumps(loads(dumps(r))) but
that r <> loads(dumps(r)).

My question now moves to: How can I test/verify my pickled data?  or is
it that is the dumps match I'm ok?  (sound good to me, but are there

from pickle import *
class R:
 def __init__(self):
  self.a = {}
  self.b = {}

print r == loads(dumps(r))
print dumps(r) == dumps(loads(dumps(r)))



Emile van Sebille
emile at

More information about the Python-list mailing list