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):
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):
if (self.check_constant_value_not_set and
if (not self.reevaluate and
node.constant_result is not ExprNodes.constant_value_not_set):
return
......
......@@ -2350,9 +2350,7 @@ class ReplaceFusedTypeChecks(VisitorTransform):
# Defer the import until now to avoid circularity...
from Cython.Compiler import Optimize
transform = Optimize.ConstantFolding()
transform.check_constant_value_not_set = False
transform = Optimize.ConstantFolding(reevaluate=True)
def __init__(self, local_scope):
super(ReplaceFusedTypeChecks, self).__init__()
......@@ -2371,8 +2369,8 @@ class ReplaceFusedTypeChecks(VisitorTransform):
type2 = node.operand2.analyse_as_type(self.local_scope)
if type1 and type2:
false = ExprNodes.BoolNode(node.pos, value=False)
true = ExprNodes.BoolNode(node.pos, value=True)
false_node = ExprNodes.BoolNode(node.pos, value=False)
true_node = ExprNodes.BoolNode(node.pos, value=True)
type1 = self.specialize_type(type1, node.operand1.pos)
op = node.operator
......@@ -2384,7 +2382,7 @@ class ReplaceFusedTypeChecks(VisitorTransform):
eq = op in ('is', '==')
if (is_same and eq) or (not is_same and not eq):
return true
return true_node
elif op in ('in', 'not_in'):
# We have to do an instance check directly, as operand2
......@@ -2404,14 +2402,14 @@ class ReplaceFusedTypeChecks(VisitorTransform):
for specific_type in types:
if type1.same_as(specific_type):
if op == 'in':
return true
return true_node
else:
return false
return false_node
if op == 'not_in':
return true
return true_node
return false
return false_node
return node
......
......@@ -19,10 +19,6 @@ from distutils.dir_util import mkpath
from distutils.command import build_ext as _build_ext
from distutils import sysconfig
if sys.version_info < (3, 0):
from Cython.Utils import any
extension_name_re = _build_ext.extension_name_re
show_compilers = _build_ext.show_compilers
......@@ -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
# of any Extension module, disable optimization for the C or C++
# compiler.
if (self.pyrex_gdb or any([getattr(ext, 'pyrex_gdb', False)
for ext in self.extensions])):
if self.pyrex_gdb or [1 for ext in self.extensions
if getattr(ext, 'pyrex_gdb', False)]:
optimization.disable_optimization()
_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