Add __slots__ where appropriate to data classes.

This commit is contained in:
Rapptz
2015-12-19 06:18:12 -05:00
parent 4fa5b50d2b
commit f1f0e169e4
10 changed files with 33 additions and 12 deletions

View File

@ -25,6 +25,8 @@ DEALINGS IN THE SOFTWARE.
"""
class EqualityComparable:
__slots__ = []
def __eq__(self, other):
return isinstance(other, self.__class__) and other.id == self.id
@ -34,5 +36,7 @@ class EqualityComparable:
return True
class Hashable(EqualityComparable):
__slots__ = []
def __hash__(self):
return hash(self.id)