Commit ca393626 authored by Mark Florisson's avatar Mark Florisson

Fix some code style issues

parent 106812c1
...@@ -3069,10 +3069,16 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): ...@@ -3069,10 +3069,16 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
into a single node. into a single node.
""" """
check_constant_value_not_set = True def __init__(self, reevaluate=False):
"""
The reevaluate argument specifies whether constant values that were
previously computed should be recomputed.
"""
super(ConstantFolding, self).__init__()
self.reevaluate = reevaluate
def _calculate_const(self, node): def _calculate_const(self, node):
if (self.check_constant_value_not_set and if (not self.reevaluate and
node.constant_result is not ExprNodes.constant_value_not_set): node.constant_result is not ExprNodes.constant_value_not_set):
return return
......
...@@ -2350,9 +2350,7 @@ class ReplaceFusedTypeChecks(VisitorTransform): ...@@ -2350,9 +2350,7 @@ class ReplaceFusedTypeChecks(VisitorTransform):
# Defer the import until now to avoid circularity... # Defer the import until now to avoid circularity...
from Cython.Compiler import Optimize from Cython.Compiler import Optimize
transform = Optimize.ConstantFolding(reevaluate=True)
transform = Optimize.ConstantFolding()
transform.check_constant_value_not_set = False
def __init__(self, local_scope): def __init__(self, local_scope):
super(ReplaceFusedTypeChecks, self).__init__() super(ReplaceFusedTypeChecks, self).__init__()
...@@ -2371,8 +2369,8 @@ class ReplaceFusedTypeChecks(VisitorTransform): ...@@ -2371,8 +2369,8 @@ class ReplaceFusedTypeChecks(VisitorTransform):
type2 = node.operand2.analyse_as_type(self.local_scope) type2 = node.operand2.analyse_as_type(self.local_scope)
if type1 and type2: if type1 and type2:
false = ExprNodes.BoolNode(node.pos, value=False) false_node = ExprNodes.BoolNode(node.pos, value=False)
true = ExprNodes.BoolNode(node.pos, value=True) true_node = ExprNodes.BoolNode(node.pos, value=True)
type1 = self.specialize_type(type1, node.operand1.pos) type1 = self.specialize_type(type1, node.operand1.pos)
op = node.operator op = node.operator
...@@ -2384,7 +2382,7 @@ class ReplaceFusedTypeChecks(VisitorTransform): ...@@ -2384,7 +2382,7 @@ class ReplaceFusedTypeChecks(VisitorTransform):
eq = op in ('is', '==') eq = op in ('is', '==')
if (is_same and eq) or (not is_same and not eq): if (is_same and eq) or (not is_same and not eq):
return true return true_node
elif op in ('in', 'not_in'): elif op in ('in', 'not_in'):
# We have to do an instance check directly, as operand2 # We have to do an instance check directly, as operand2
...@@ -2404,14 +2402,14 @@ class ReplaceFusedTypeChecks(VisitorTransform): ...@@ -2404,14 +2402,14 @@ class ReplaceFusedTypeChecks(VisitorTransform):
for specific_type in types: for specific_type in types:
if type1.same_as(specific_type): if type1.same_as(specific_type):
if op == 'in': if op == 'in':
return true return true_node
else: else:
return false return false_node
if op == 'not_in': if op == 'not_in':
return true return true_node
return false return false_node
return node return node
......
...@@ -19,10 +19,6 @@ from distutils.dir_util import mkpath ...@@ -19,10 +19,6 @@ from distutils.dir_util import mkpath
from distutils.command import build_ext as _build_ext from distutils.command import build_ext as _build_ext
from distutils import sysconfig from distutils import sysconfig
if sys.version_info < (3, 0):
from Cython.Utils import any
extension_name_re = _build_ext.extension_name_re extension_name_re = _build_ext.extension_name_re
show_compilers = _build_ext.show_compilers show_compilers = _build_ext.show_compilers
...@@ -122,8 +118,8 @@ class build_ext(_build_ext.build_ext): ...@@ -122,8 +118,8 @@ class build_ext(_build_ext.build_ext):
# If --pyrex-gdb is in effect as a command line option or as option # If --pyrex-gdb is in effect as a command line option or as option
# of any Extension module, disable optimization for the C or C++ # of any Extension module, disable optimization for the C or C++
# compiler. # compiler.
if (self.pyrex_gdb or any([getattr(ext, 'pyrex_gdb', False) if self.pyrex_gdb or [1 for ext in self.extensions
for ext in self.extensions])): if getattr(ext, 'pyrex_gdb', False)]:
optimization.disable_optimization() optimization.disable_optimization()
_build_ext.build_ext.run(self) _build_ext.build_ext.run(self)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment