[pypy-svn] r11947 - pypy/dist/pypy/objspace/std
tismer at codespeak.net
tismer at codespeak.net
Wed May 4 23:21:34 CEST 2005
Author: tismer
Date: Wed May 4 23:21:33 2005
New Revision: 11947
Modified:
pypy/dist/pypy/objspace/std/intobject.py
pypy/dist/pypy/objspace/std/longobject.py
Log:
tiny cleanups like un-overflow-checking an operation.
synchronized the way long and ints decide about floordiv
Modified: pypy/dist/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/intobject.py (original)
+++ pypy/dist/pypy/objspace/std/intobject.py Wed May 4 23:21:33 2005
@@ -178,13 +178,12 @@
y = w_int2.intval
try:
z = ovfcheck(x // y)
- t = ovfcheck(x % y)
except ZeroDivisionError:
raise OperationError(space.w_ZeroDivisionError,
space.wrap("integer division by zero"))
except OverflowError:
return space.div(space.newfloat(float(x)), w_int2)
- if t != 0: # gives a float
+ if x % y != 0: # gives a float
return space.div(space.newfloat(float(x)), w_int2)
return W_IntObject(space, z)
Modified: pypy/dist/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longobject.py (original)
+++ pypy/dist/pypy/objspace/std/longobject.py Wed May 4 23:21:33 2005
@@ -275,7 +275,13 @@
z = x // y
return W_LongObject(space, *args_from_long(z))
-div__Long_Long = floordiv__Long_Long #YYYYYY
+old_style_div = 1 / 2 == 1 // 2
+def div__Long_Long(space, w_long1, w_long2): #YYYYYY
+ # Select the proper div
+ if old_style_div:
+ return floordiv__Long_Long(space, w_long1, w_long2)
+ else:
+ return truediv__Long_Long(space, w_long1, w_long2)
def mod__Long_Long(space, w_long1, w_long2): #YYYYYY
More information about the Pypy-commit
mailing list