summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Optimize.py
diff options
context:
space:
mode:
Diffstat (limited to 'Cython/Compiler/Optimize.py')
-rw-r--r--Cython/Compiler/Optimize.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py
index a601d18c9..231d23419 100644
--- a/Cython/Compiler/Optimize.py
+++ b/Cython/Compiler/Optimize.py
@@ -319,16 +319,6 @@ class IterationTransform(Visitor.EnvTransform):
return self._optimise_for_loop(node, arg, reversed=True)
- PyBytes_AS_STRING_func_type = PyrexTypes.CFuncType(
- PyrexTypes.c_char_ptr_type, [
- PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None)
- ])
-
- PyBytes_GET_SIZE_func_type = PyrexTypes.CFuncType(
- PyrexTypes.c_py_ssize_t_type, [
- PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None)
- ])
-
def _transform_indexable_iteration(self, node, slice_node, is_mutable, reversed=False):
"""In principle can handle any iterable that Cython has a len() for and knows how to index"""
unpack_temp_node = UtilNodes.LetRefNode(
@@ -415,6 +405,16 @@ class IterationTransform(Visitor.EnvTransform):
body.stats.insert(1, node.body)
return ret
+ PyBytes_AS_STRING_func_type = PyrexTypes.CFuncType(
+ PyrexTypes.c_char_ptr_type, [
+ PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None)
+ ])
+
+ PyBytes_GET_SIZE_func_type = PyrexTypes.CFuncType(
+ PyrexTypes.c_py_ssize_t_type, [
+ PyrexTypes.CFuncTypeArg("s", Builtin.bytes_type, None)
+ ])
+
def _transform_bytes_iteration(self, node, slice_node, reversed=False):
target_type = node.target.type
if not target_type.is_int and target_type is not Builtin.bytes_type:
@@ -2105,7 +2105,8 @@ class InlineDefNodeCalls(Visitor.NodeRefCleanupMixin, Visitor.EnvTransform):
return node
inlined = ExprNodes.InlinedDefNodeCallNode(
node.pos, function_name=function_name,
- function=function, args=node.args)
+ function=function, args=node.args,
+ generator_arg_tag=node.generator_arg_tag)
if inlined.can_be_inlined():
return self.replace(node, inlined)
return node
@@ -3026,7 +3027,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
"""Optimistic optimisation as X.append() is almost always
referring to a list.
"""
- if len(args) != 2 or node.result_is_used:
+ if len(args) != 2 or node.result_is_used or node.function.entry:
return node
return ExprNodes.PythonCapiCallNode(