From 6799bb88be108214d64cbaf1b787c1e404088884 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Tue, 18 Feb 2014 11:57:30 -0600 Subject: [PATCH] Move equality comparison to Record (which has pickling, as used by equality comparison) --- pytools/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index fcaaafc..f86c3b0 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -154,13 +154,6 @@ class RecordWithoutPickling(object): for fld in self.__class__.fields if hasattr(self, fld))) - def __eq__(self, other): - return (self.__class__ == other.__class__ - and self.__getstate__() == other.__getstate__()) - - def __ne__(self, other): - return not self.__eq__(other) - class Record(RecordWithoutPickling): __slots__ = [] @@ -180,6 +173,14 @@ class Record(RecordWithoutPickling): for key, value in valuedict.iteritems(): fields.add(key) setattr(self, key, value) + + def __eq__(self, other): + return (self.__class__ == other.__class__ + and self.__getstate__() == other.__getstate__()) + + def __ne__(self, other): + return not self.__eq__(other) + # }}} -- GitLab