[pypy-svn] r17442 - pypy/dist/pypy/rpython

arigo at codespeak.net arigo at codespeak.net
Sat Sep 10 15:06:00 CEST 2005

Author: arigo
Date: Sat Sep 10 15:05:59 2005
New Revision: 17442

A hash function that hashes any pointer by identity is more dangerous
than helpful.  For example the hash can be used for a prebuilt dict,
when the pointer will change between compile-time and run-time.

If needed, we can add logic in rclass.py to support instances as keys
in dictionaries, linked to the hash-preserving code already there.

Modified: pypy/dist/pypy/rpython/rmodel.py
--- pypy/dist/pypy/rpython/rmodel.py	(original)
+++ pypy/dist/pypy/rpython/rmodel.py	Sat Sep 10 15:05:59 2005
@@ -102,10 +102,7 @@
         raise TyperError, 'no equality function for %r' % self
     def get_ll_hash_function(self):
-        if not isinstance(self.lowleveltype, Ptr):
-            raise TyperError, 'no hashing function for %r' % self
-        # default behavior: use the pointer identity as a hash
-        return ll_hash_ptr
+        raise TyperError, 'no hashing function for %r' % self
     def rtype_bltn_list(self, hop):
         raise TyperError, 'no list() support for %r' % self
@@ -158,9 +155,6 @@
     def make_iterator_repr(self, *variant):
         raise TyperError("%s is not iterable" % (self,))
-def ll_hash_ptr(p):
-    return cast_ptr_to_int(p)
 def ll_hash_void(v):
     return 0

More information about the Pypy-commit mailing list