[pypy-svn] r62493 - pypy/trunk/pypy/rpython/ootypesystem

afa at codespeak.net afa at codespeak.net
Tue Mar 3 19:21:31 CET 2009

Author: afa
Date: Tue Mar  3 19:21:29 2009
New Revision: 62493

in oosupport/constant.py, the constants cache store objects of different 
types in a dictionary: all keys should be comparable.

I was unlucky enough to have two objects with the same hash.
but this can be explained if one was a _view of the other.
Change a bit the __hash__ function to reduce collisions.

Modified: pypy/trunk/pypy/rpython/ootypesystem/ootype.py
--- pypy/trunk/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/trunk/pypy/rpython/ootypesystem/ootype.py	Tue Mar  3 19:21:29 2009
@@ -913,13 +913,13 @@
         return not (self == other)
     def __eq__(self, other):
-        assert isinstance(other, _view)
+        assert isinstance(other, (_view, _callable))
         a = self._inst
         b = other._inst
         return a.__class__ == b.__class__ and a == b
     def __hash__(self):
-        return hash(self._inst)
+        return hash(self._inst) + 1
     def __nonzero__(self):
         return bool(self._inst)

More information about the Pypy-commit mailing list