class C(object):

    def __init__(self, i):
        self.i = i


class D(C):

    def __init__(self, i, j):
        super(D, self).__init__(i)
self.j = j

def __getstate__(self):
    return self.__dict__

def __setstate__(self, d):
    self.__dict__ = d
d = pickle.loads(pickle.dumps(D(1, 2), -1))
assert d.i == 1
assert d.j == 2
Simple example of use of __setstate__ and __getstate__