Task: optimize == and != _hash_key comparison
authorZac Medico <zmedico@gentoo.org>
Fri, 20 May 2011 20:40:13 +0000 (13:40 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 May 2011 03:36:17 +0000 (20:36 -0700)
pym/_emerge/Task.py

index 4dbdb11854f0cfa95210b117c1551c0a7dde1596..3e1a4ba629aedabc97d0d4c5517e7375ba505296 100644 (file)
@@ -6,10 +6,16 @@ class Task(SlotObject):
        __slots__ = ("_hash_key", "_hash_value")
 
        def __eq__(self, other):
-               return self._hash_key == other
+               try:
+                       return self._hash_key == other._hash_key
+               except AttributeError:
+                       return False
 
        def __ne__(self, other):
-               return self._hash_key != other
+               try:
+                       return self._hash_key != other._hash_key
+               except AttributeError:
+                       return True
 
        def __hash__(self):
                return self._hash_value