[pypy-svn] pypy cmath: Temporary fix: still call it 'self.key', and only have a special

arigo commits-noreply at bitbucket.org
Tue Jan 18 13:31:58 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: cmath
Changeset: r40845:5bfe19f2e3d9
Date: 2011-01-18 13:31 +0100
http://bitbucket.org/pypy/pypy/changeset/5bfe19f2e3d9/

Log:	Temporary fix: still call it 'self.key', and only have a special
	value for -0.0.

diff --git a/pypy/tool/uid.py b/pypy/tool/uid.py
--- a/pypy/tool/uid.py
+++ b/pypy/tool/uid.py
@@ -38,7 +38,7 @@
     key in dictionaries.  This is based on id() for mutable objects and on
     real hash/compare for immutable ones.
     """
-    __slots__ = ["_key", "value"]
+    __slots__ = ["key", "value"]
     
     def __init__(self, value):
         self.value = value     # a concrete value
@@ -49,25 +49,23 @@
         # translating the cmath module)
         if key[0] is float and not self.value:
             from pypy.rlib.rarithmetic import copysign
-            if copysign(1., self.value) == 1.:    # +0.0
-                key = (float, "+0.0")
-            else:
+            if copysign(1., self.value) == -1.:    # -0.0
                 key = (float, "-0.0")
         #
         try:
             hash(key)
         except TypeError:
             key = id(self.value)
-        self._key = key
+        self.key = key
 
     def __eq__(self, other):
-        return self.__class__ is other.__class__ and self._key == other._key
+        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._key)
+        return hash(self.key)
 
     def __repr__(self):
         return '(%s)' % (self,)


More information about the Pypy-commit mailing list