[pypy-svn] r62737 - pypy/trunk/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Sun Mar 8 21:19:04 CET 2009


Author: fijal
Date: Sun Mar  8 21:19:02 2009
New Revision: 62737

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/llmemory.py
Log:
provide a hash for llmemory.Address. This is needed when having a prebuilt
dict of Address keys, the creation of rdict takes forever


Modified: pypy/trunk/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/llmemory.py	Sun Mar  8 21:19:02 2009
@@ -411,6 +411,11 @@
     def __nonzero__(self):
         return self.ptr is not None
 
+    def __hash__(self):
+        if not self._fixup().ptr:
+            return 0
+        return hash(self._fixup().ptr._obj)
+
     def __eq__(self, other):
         if isinstance(other, fakeaddress):
             obj1 = self._fixup().ptr



More information about the Pypy-commit mailing list