[pypy-commit] pypy remove-remaining-smm: Kill W_AbstractFloatObject, its only subclass is W_FloatObject.

Manuel Jacob noreply at buildbot.pypy.org
Mon Feb 24 04:10:16 CET 2014


Author: Manuel Jacob
Branch: remove-remaining-smm
Changeset: r69327:0893e9d51fd5
Date: 2014-02-24 02:54 +0100
http://bitbucket.org/pypy/pypy/changeset/0893e9d51fd5/

Log:	Kill W_AbstractFloatObject, its only subclass is W_FloatObject.

diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -25,33 +25,6 @@
 float_hex = SMM("hex", 1)
 
 
-class W_AbstractFloatObject(W_Object):
-    __slots__ = ()
-
-    def is_w(self, space, w_other):
-        from rpython.rlib.longlong2float import float2longlong
-        if not isinstance(w_other, W_AbstractFloatObject):
-            return False
-        if self.user_overridden_class or w_other.user_overridden_class:
-            return self is w_other
-        one = float2longlong(space.float_w(self))
-        two = float2longlong(space.float_w(w_other))
-        return one == two
-
-    def immutable_unique_id(self, space):
-        if self.user_overridden_class:
-            return None
-        from rpython.rlib.longlong2float import float2longlong
-        from pypy.objspace.std.model import IDTAG_FLOAT as tag
-        val = float2longlong(space.float_w(self))
-        b = rbigint.fromrarith_int(val)
-        b = b.lshift(3).or_(rbigint.fromint(tag))
-        return space.newlong_from_rbigint(b)
-
-    def int(self, space):
-        raise NotImplementedError
-
-
 def detect_floatformat():
     from rpython.rtyper.lltypesystem import rffi, lltype
     buf = lltype.malloc(rffi.CCHARP.TO, 8, flavor='raw')
@@ -154,7 +127,7 @@
     return _compare
 
 
-class W_FloatObject(W_AbstractFloatObject):
+class W_FloatObject(W_Object):
     """This is a implementation of the app-level 'float' type.
     The constructor takes an RPython float as an argument."""
     _immutable_fields_ = ['floatval']
@@ -179,6 +152,26 @@
         else:
             return space.newint(value)
 
+    def is_w(self, space, w_other):
+        from rpython.rlib.longlong2float import float2longlong
+        if not isinstance(w_other, W_FloatObject):
+            return False
+        if self.user_overridden_class or w_other.user_overridden_class:
+            return self is w_other
+        one = float2longlong(space.float_w(self))
+        two = float2longlong(space.float_w(w_other))
+        return one == two
+
+    def immutable_unique_id(self, space):
+        if self.user_overridden_class:
+            return None
+        from rpython.rlib.longlong2float import float2longlong
+        from pypy.objspace.std.model import IDTAG_FLOAT as tag
+        val = float2longlong(space.float_w(self))
+        b = rbigint.fromrarith_int(val)
+        b = b.lshift(3).or_(rbigint.fromint(tag))
+        return space.newlong_from_rbigint(b)
+
     def __repr__(self):
         return "<W_FloatObject(%f)>" % self.floatval
 
@@ -578,7 +571,7 @@
     conjugate = interp2app(W_FloatObject.descr_conjugate),
     real = GetSetProperty(W_FloatObject.descr_get_real),
     imag = GetSetProperty(W_FloatObject.descr_get_imag),
-    __int__ = interpindirect2app(W_AbstractFloatObject.int),
+    __int__ = interpindirect2app(W_FloatObject.int),
 )
 W_FloatObject.typedef.registermethods(globals())
 


More information about the pypy-commit mailing list