[pypy-svn] r36977 - in pypy/dist/pypy: doc objspace/std rlib rlib/test

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Jan 19 00:10:11 CET 2007


Author: cfbolz
Date: Fri Jan 19 00:10:09 2007
New Revision: 36977

Added:
   pypy/dist/pypy/rlib/rbigint.py
      - copied, changed from r36720, pypy/dist/pypy/rlib/rlong.py
   pypy/dist/pypy/rlib/test/test_rbigint.py
      - copied, changed from r36720, pypy/dist/pypy/rlib/test/test_rlong.py
Removed:
   pypy/dist/pypy/rlib/rlong.py
   pypy/dist/pypy/rlib/test/test_rlong.py
Modified:
   pypy/dist/pypy/doc/rlib.txt
   pypy/dist/pypy/objspace/std/longobject.py
   pypy/dist/pypy/objspace/std/marshal_impl.py
Log:
issue 281 resolved

thanks again, janzert!


Modified: pypy/dist/pypy/doc/rlib.txt
==============================================================================
--- pypy/dist/pypy/doc/rlib.txt	(original)
+++ pypy/dist/pypy/doc/rlib.txt	Fri Jan 19 00:10:09 2007
@@ -109,20 +109,20 @@
 .. _`coding guide`: coding-guide.html
 
 
-``rlong``
-=========
+``rbigint``
+===========
 
-The rlong_ module contains a full RPython implementation of the Python ``long``
-type (which itself is not supported in RPython). The ``rlong`` class contains
-that implementation. To construct ``rlong`` instances use the static methods
+The rbigint module contains a full RPython implementation of the Python ``long``
+type (which itself is not supported in RPython). The ``rbigint`` class contains
+that implementation. To construct ``rbigint`` instances use the static methods
 ``fromint``, ``frombool``, ``fromfloat`` and ``fromdecimalstr``. To convert back
 to other types use the methods ``toint``, ``tobool``, ``touint`` and
 ``tofloat``. Since RPython does not support operator overloading, all the
-special methods of ``rlong`` that would normally start and end with "__" have
+special methods of ``rbigint`` that would normally start and end with "__" have
 these underscores left out for better readability (so ``a.add(b)`` can be used
-to add two rlongs).
+to add two rbigint).
 
-.. _rlong: ../../pypy/rlib/rlong.py
+.. _rbigint: ../../pypy/rlib/rbigint.py
 
 
 ``rrandom``

Modified: pypy/dist/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longobject.py	(original)
+++ pypy/dist/pypy/objspace/std/longobject.py	Fri Jan 19 00:10:09 2007
@@ -2,17 +2,17 @@
 from pypy.objspace.std.objspace import *
 from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.noneobject import W_NoneObject
-from pypy.rlib.rlong import rlong, SHIFT
+from pypy.rlib.rbigint import rbigint, SHIFT
 
 class W_LongObject(W_Object):
-    """This is a wrapper of rlong."""
+    """This is a wrapper of rbigint."""
     from pypy.objspace.std.longtype import long_typedef as typedef
     
     def __init__(w_self, l):
-        w_self.num = l # instance of rlong
+        w_self.num = l # instance of rbigint
 
     def fromint(space, intval):
-        return W_LongObject(rlong.fromint(intval))
+        return W_LongObject(rbigint.fromint(intval))
     fromint = staticmethod(fromint)
 
     def longval(self):
@@ -28,20 +28,20 @@
         return self.num.toint()
 
     def fromfloat(f):
-        return W_LongObject(rlong.fromfloat(f))
+        return W_LongObject(rbigint.fromfloat(f))
     fromfloat = staticmethod(fromfloat)
 
     def fromlong(l):
-        return W_LongObject(rlong.fromlong(l))
+        return W_LongObject(rbigint.fromlong(l))
     fromlong = staticmethod(fromlong)
 
     def fromrarith_int(i):
-        return W_LongObject(rlong.fromrarith_int(i))
+        return W_LongObject(rbigint.fromrarith_int(i))
     fromrarith_int._annspecialcase_ = "specialize:argtype(0)"
     fromrarith_int = staticmethod(fromrarith_int)
 
     def fromdecimalstr(s):
-        return W_LongObject(rlong.fromdecimalstr(s))
+        return W_LongObject(rbigint.fromdecimalstr(s))
     fromdecimalstr = staticmethod(fromdecimalstr)
 
     def _count_bits(self):
@@ -54,7 +54,7 @@
 
 # bool-to-long
 def delegate_Bool2Long(space, w_bool):
-    return W_LongObject(rlong.frombool(space.is_true(w_bool)))
+    return W_LongObject(rbigint.frombool(space.is_true(w_bool)))
 
 # int-to-long delegation
 def delegate_Int2Long(space, w_intobj):
@@ -170,7 +170,7 @@
 
 def pow__Long_Long_Long(space, w_long1, w_long2, w_long3):
     # XXX need to replicate some of the logic, to get the errors right
-    if w_long2.num.lt(rlong.fromint(0)):
+    if w_long2.num.lt(rbigint.fromint(0)):
         raise OperationError(
             space.w_TypeError,
             space.wrap(
@@ -184,7 +184,7 @@
 
 def pow__Long_Long_None(space, w_long1, w_long2, w_long3):
     # XXX need to replicate some of the logic, to get the errors right
-    if w_long2.num.lt(rlong.fromint(0)):
+    if w_long2.num.lt(rbigint.fromint(0)):
         raise FailedToImplement(
             space.w_ValueError,
             space.wrap("long pow() too negative"))
@@ -207,7 +207,7 @@
 
 def lshift__Long_Long(space, w_long1, w_long2):
     # XXX need to replicate some of the logic, to get the errors right
-    if w_long2.num.lt(rlong.fromint(0)):
+    if w_long2.num.lt(rbigint.fromint(0)):
         raise OperationError(space.w_ValueError,
                              space.wrap("negative shift count"))
     try:
@@ -218,7 +218,7 @@
 
 def rshift__Long_Long(space, w_long1, w_long2):
     # XXX need to replicate some of the logic, to get the errors right
-    if w_long2.num.lt(rlong.fromint(0)):
+    if w_long2.num.lt(rbigint.fromint(0)):
         raise OperationError(space.w_ValueError,
                              space.wrap("negative shift count"))
     try:

Modified: pypy/dist/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/dist/pypy/objspace/std/marshal_impl.py	(original)
+++ pypy/dist/pypy/objspace/std/marshal_impl.py	Fri Jan 19 00:10:09 2007
@@ -253,7 +253,7 @@
         m.put_short(digit)
 
 def unmarshal_Long(space, u, tc):
-    from pypy.rlib import rlong
+    from pypy.rlib import rbigint
     lng = u.get_int()
     if lng < 0:
         sign = -1
@@ -271,7 +271,7 @@
         digits[i] = digit
         i += 1
     # XXX poking at internals
-    w_long = W_LongObject(rlong.rlong(digits, sign))
+    w_long = W_LongObject(rbigint.rbigint(digits, sign))
     w_long.num._normalize()
     return w_long
 register(TYPE_LONG, unmarshal_Long)



More information about the Pypy-commit mailing list