Commits

Amaury Forgeot d'Arc committed 4c46f70

There is only one True Division.

Comments (0)

Files changed (3)

pypy/interpreter/astcompiler/codegen.py

     ast.Add : ops.BINARY_ADD,
     ast.Sub : ops.BINARY_SUBTRACT,
     ast.Mult : ops.BINARY_MULTIPLY,
+    ast.Div : ops.BINARY_TRUE_DIVIDE,
     ast.Mod : ops.BINARY_MODULO,
     ast.Pow : ops.BINARY_POWER,
     ast.LShift : ops.BINARY_LSHIFT,
     ast.Add : ops.INPLACE_ADD,
     ast.Sub : ops.INPLACE_SUBTRACT,
     ast.Mult : ops.INPLACE_MULTIPLY,
+    ast.Div : ops.INPLACE_TRUE_DIVIDE,
     ast.Mod : ops.INPLACE_MODULO,
     ast.Pow : ops.INPLACE_POWER,
     ast.LShift : ops.INPLACE_LSHIFT,
         self.name_op(cls.name, ast.Store)
 
     def _op_for_augassign(self, op):
-        if op == ast.Div:
-            if self.compile_info.flags & consts.CO_FUTURE_DIVISION:
-                return ops.INPLACE_TRUE_DIVIDE
-            else:
-                return ops.INPLACE_DIVIDE
         return inplace_operations(op)
 
     def visit_AugAssign(self, assign):
         self.use_next_block(end)
 
     def _binop(self, op):
-        if op == ast.Div:
-            if self.compile_info.flags & consts.CO_FUTURE_DIVISION:
-                return ops.BINARY_TRUE_DIVIDE
-            else:
-                return ops.BINARY_DIVIDE
         return binary_operations(op)
 
     def visit_BinOp(self, binop):

pypy/interpreter/astcompiler/optimize.py

             right = binop.right.as_constant()
             if right is not None:
                 op = binop.op
-                # Can't fold straight division without "from __future_ import
-                # division" because it might be affected at runtime by the -Q
-                # flag.
-                if op == ast.Div and \
-                        not self.compile_info.flags & consts.CO_FUTURE_DIVISION:
-                    return binop
                 try:
                     for op_kind, folder in unrolling_binary_folders:
                         if op_kind == op:

pypy/interpreter/astcompiler/test/test_compiler.py

+from __future__ import division
 import py
 from pypy.interpreter.astcompiler import codegen, astbuilder, symtable, optimize
 from pypy.interpreter.pyparser import pyparse