From 8f1bc5944b849f3ad0cbbd5972d5ab9948ed4d57 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Sat, 2 May 2020 11:01:35 -0400 Subject: Fix up equality operators and had hash operators --- python/transform.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'python/transform.py') diff --git a/python/transform.py b/python/transform.py index 946b349b..3e89555d 100644 --- a/python/transform.py +++ b/python/transform.py @@ -166,15 +166,18 @@ class Transform(with_metaclass(_TransformMetaClass, object)): def __repr__(self): return "" % self.name - def __eq__(self, value): - if not isinstance(value, Transform): - return False - return ctypes.addressof(self.handle.contents) == ctypes.addressof(value.handle.contents) + def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents) - def __ne__(self, value): - if not isinstance(value, Transform): - return True - return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + def __ne__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return not (self == other) + + def __hash__(self): + return hash(ctypes.addressof(self.handle.contents)) def _get_parameters(self, ctxt, count): try: -- cgit v1.3.1