Hello, I have code like the following
class B1(): __slots__ = [xxx] # B1 does not have setstate/getstate # but pickle can pickle B1 by default way. class B2(B1): __slots__ = [xxx] # The derived chain is long class B3(B2): __slots__ = [xxx] # But all of them can be pickle by default behavior ... class D(Bn): __slots__ = [xxx] # D has some non trivial behavior, I need to customize pickle behavior def __getstate__(self): # How should I do here? def __setstate__(self, state): # And here?
class B does not defined
getstate/setstate, I cannot call
Since they have defined
__slots__ I cannot pickle
Since the deriving chain is long, I think it is a bad idea to define
getstate/setstate for all of base class
What should I do?