__getstate__ implementation based on tuple and ordered __slots__
is slightly faster than implementation based on dicts.
It also produces smaller blobs.
Speed of this implementation is +- few percents the same
as it was in dnspython 1.16.0 and it now produces smaller blobs.
Fixes: #485
# Rdatas are immutable
raise TypeError("object doesn't support attribute deletion")
+ def __getstate__(self):
+ return tuple(getattr(self, slot) for slot in self.__slots__)
+
+ def __setstate__(self, state):
+ for slot, val in zip(self.__slots__, state):
+ object.__setattr__(self, slot, val)
+
def covers(self):
"""Return the type a Rdata covers.