From 6dddcdf40fec90d4eaab3417b67dcc849c2547c7 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 20 May 2011 13:40:13 -0700 Subject: [PATCH] Task: optimize == and != _hash_key comparison --- pym/_emerge/Task.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pym/_emerge/Task.py b/pym/_emerge/Task.py index 4dbdb1185..3e1a4ba62 100644 --- a/pym/_emerge/Task.py +++ b/pym/_emerge/Task.py @@ -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 -- 2.26.2