I have an extension module for Python that uses SWIG as a wrapper and I try to serialize it with Pickle and I fail =)
Seems like I found simlple solution that works for me:
So let's say we have class C that was generated with SWIG, then we wrap it with
class PickalableC(C, PickalableSWIG):
def __init__(self, *args):
self.args = args
C.__init__(self)
where PickalableSWIG is
class PickalableSWIG:
def __setstate__(self, state):
self.__init__(*state['args'])
def __getstate__(self):
return {'args': self.args}
Then
pickle.loads(pickle.dumps(C()))
fails, but
pickle.loads(pickle.dumps(PickalableC()))
succeeds =)