[pypy-svn] r7251 - pypy/trunk/src/pypy/objspace/flow

arigo at codespeak.net arigo at codespeak.net
Mon Nov 15 17:30:47 CET 2004


Author: arigo
Date: Mon Nov 15 17:30:46 2004
New Revision: 7251

Modified:
   pypy/trunk/src/pypy/objspace/flow/model.py
Log:
Oups.  This goes together with the previous check-in.


Modified: pypy/trunk/src/pypy/objspace/flow/model.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/model.py	(original)
+++ pypy/trunk/src/pypy/objspace/flow/model.py	Mon Nov 15 17:30:46 2004
@@ -100,15 +100,22 @@
 class Constant:
     def __init__(self, value):
         self.value = value     # a concrete value
+        # try to be smart about constant mutable or immutable values
+        key = type(self.value), self.value  # to avoid confusing e.g. 0 and 0.0
+        try:
+            hash(key)
+        except TypeError:
+            key = id(self.value)
+        self.key = key
 
     def __eq__(self, other):
-        return self.__class__ is other.__class__ and self.value == other.value
+        return self.__class__ is other.__class__ and self.key == other.key
 
     def __ne__(self, other):
         return not (self == other)
 
     def __hash__(self):
-        return hash(self.value)
+        return hash(self.key)
 
     def __repr__(self):
         # try to limit the size of the repr to make it more readable



More information about the Pypy-commit mailing list