Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: py3k Changeset: r47954:4c46f703ae28 Date: 2011-10-12 00:16 +0200 http://bitbucket.org/pypy/pypy/changeset/4c46f703ae28/
Log: There is only one True Division. diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -55,6 +55,7 @@ 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, @@ -69,6 +70,7 @@ 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, @@ -333,11 +335,6 @@ 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): @@ -380,11 +377,6 @@ 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): diff --git a/pypy/interpreter/astcompiler/optimize.py b/pypy/interpreter/astcompiler/optimize.py --- a/pypy/interpreter/astcompiler/optimize.py +++ b/pypy/interpreter/astcompiler/optimize.py @@ -175,12 +175,6 @@ 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: diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1,3 +1,4 @@ +from __future__ import division import py from pypy.interpreter.astcompiler import codegen, astbuilder, symtable, optimize from pypy.interpreter.pyparser import pyparse _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit