One way to do this is to override the __setstate__ and __getstate__ methods, which handle the dict that gets pickled. e.g.
def __getstate__(self):
d = self.__dict__.copy()
del d['swig_pointer'] # Can't pickle the underlying C++ object
d['__serialize'] = self.get_byte_string()
return d
def __setstate__(self, d):
b = d.pop('__serialize')
self.__dict__.update(d)
self.set_byte_string(b)
One way to do this is to override the
__setstate__
and__getstate__
methods, which handle the dict that gets pickled. e.g.