Author: stian
Branch: bigint-with-int
Changeset: r65917:5c7293f44084
Date: 2013-08-02 23:15 +0200
http://bitbucket.org/pypy/pypy/changeset/5c7293f44084/
Log: Add these to longobject as well. Pidigits went from 6.59s to 5.79s.
I call it progress :)
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -226,9 +226,21 @@
space.wrap("long division or modulo by zero"))
return newlong(space, z)
+def floordiv__Long_Int(space, w_long1, w_int2):
+ try:
+ z = w_long1.num.int_floordiv(w_int2.intval)
+ except ZeroDivisionError:
+ raise OperationError(space.w_ZeroDivisionError,
+ space.wrap("long division or modulo by zero"))
+ return newlong(space, z)
+
+
def div__Long_Long(space, w_long1, w_long2):
return floordiv__Long_Long(space, w_long1, w_long2)
+def div__Long_Int(space, w_long1, w_int2):
+ return floordiv__Long_Int(space, w_long1, w_int2)
+
def mod__Long_Long(space, w_long1, w_long2):
try:
z = w_long1.num.mod(w_long2.num)
@@ -253,6 +265,14 @@
space.wrap("long division or modulo by zero"))
return space.newtuple([newlong(space, div), newlong(space, mod)])
+def divmod__Long_Int(space, w_long1, w_int2):
+ try:
+ div, mod = w_long1.num.int_divmod(w_int2.intval)
+ except ZeroDivisionError:
+ raise OperationError(space.w_ZeroDivisionError,
+ space.wrap("long division or modulo by zero"))
+ return space.newtuple([newlong(space, div), newlong(space, mod)])
+
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.sign < 0:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit