Add __slots__ where appropriate to data classes.

This commit is contained in:
Rapptz committed 2015-12-19 06:18:12 -05:00
1 parent 4fa5b50d2b
commit f1f0e169e4
10 files changed
+33 -12

No files matched your search

+4
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)