Author: Maciej Fijalkowski <fij...@gmail.com>
Branch: 
Changeset: r67555:72c1e31475e9
Date: 2013-10-23 14:28 +0200
http://bitbucket.org/pypy/pypy/changeset/72c1e31475e9/

Log:    an attempt to make it faster to compute inequality of some stuff

diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -97,8 +97,13 @@
     def __eq__(self, other):
         if isinstance(other, Typedef):
             return other.__eq__(self)
-        return self.__class__ is other.__class__ and (
-            self is other or safe_equal(self.__dict__, other.__dict__))
+        if self.__class__ is other.__class__:
+            if self is other:
+                return True
+            if hash(self) != hash(other):
+                return False
+            return safe_equal(self.__dict__, other.__dict__)
+        return False
 
     def __ne__(self, other):
         return not (self == other)
@@ -227,6 +232,9 @@
         self.OF = OF
         self.c_name = c_name
 
+    def __hash__(self):
+        return hash(self.OF)
+
     def __repr__(self):
         return '<Typedef "%s" of %r>' % (self.c_name, self.OF)
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to