Author: Philip Jenvey <pjen...@underboss.org>
Branch: stdlib-2.7.12
Changeset: r87525:3e88e4b495e3
Date: 2016-10-02 12:22 -0700
http://bitbucket.org/pypy/pypy/changeset/3e88e4b495e3/

Log:    simplify: W_IntObject.descr_long now returns small longs

diff --git a/pypy/objspace/std/smalllongobject.py 
b/pypy/objspace/std/smalllongobject.py
--- a/pypy/objspace/std/smalllongobject.py
+++ b/pypy/objspace/std/smalllongobject.py
@@ -128,7 +128,7 @@
                 self = _small2long(space, self)
                 return self.descr_pow(space, w_exponent, w_modulus)
         elif isinstance(w_modulus, W_AbstractIntObject):
-            w_modulus = _int2small(space, w_modulus)
+            w_modulus = w_modulus.descr_long(space)
         elif not isinstance(w_modulus, W_AbstractLongObject):
             return space.w_NotImplemented
         elif not isinstance(w_modulus, W_SmallLongObject):
@@ -151,7 +151,7 @@
     def descr_rpow(self, space, w_base, w_modulus=None):
         if isinstance(w_base, W_AbstractIntObject):
             # Defer to w_base<W_SmallLongObject>.descr_pow
-            w_base = _int2small(space, w_base)
+            w_base = w_base.descr_long(space)
         elif not isinstance(w_base, W_AbstractLongObject):
             return space.w_NotImplemented
         return w_base.descr_pow(space, self, w_modulus)
@@ -187,7 +187,7 @@
         @func_renamer(descr_name)
         def descr_binop(self, space, w_other):
             if isinstance(w_other, W_AbstractIntObject):
-                w_other = _int2small(space, w_other)
+                w_other = w_other.descr_long(space)
             elif not isinstance(w_other, W_AbstractLongObject):
                 return space.w_NotImplemented
             elif not isinstance(w_other, W_SmallLongObject):
@@ -214,7 +214,7 @@
         @func_renamer(descr_rname)
         def descr_rbinop(self, space, w_other):
             if isinstance(w_other, W_AbstractIntObject):
-                w_other = _int2small(space, w_other)
+                w_other = w_other.descr_long(space)
             elif not isinstance(w_other, W_AbstractLongObject):
                 return space.w_NotImplemented
             elif not isinstance(w_other, W_SmallLongObject):
@@ -379,11 +379,6 @@
     raise OverflowError("integer multiplication")
 
 
-def _int2small(space, w_int):
-    # XXX: W_IntObject.descr_long should probably return W_SmallLongs
-    return W_SmallLongObject.fromint(w_int.int_w(space))
-
-
 def _small2long(space, w_small):
     return W_LongObject(w_small.asbigint())
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to