Commit 9b67cc67 authored by Stefan Behnel's avatar Stefan Behnel

better type inference support for reversed()

parent 00dd1dfb
...@@ -68,6 +68,10 @@ class MarkAssignments(CythonTransform): ...@@ -68,6 +68,10 @@ class MarkAssignments(CythonTransform):
# TODO: Remove redundancy with range optimization... # TODO: Remove redundancy with range optimization...
is_special = False is_special = False
sequence = node.iterator.sequence sequence = node.iterator.sequence
if isinstance(sequence, ExprNodes.SimpleCallNode):
function = sequence.function
if function.name == 'reversed' and len(sequence.args) == 1:
sequence = sequence.args[0]
if isinstance(sequence, ExprNodes.SimpleCallNode): if isinstance(sequence, ExprNodes.SimpleCallNode):
function = sequence.function function = sequence.function
if sequence.self is None and function.is_name: if sequence.self is None and function.is_name:
...@@ -82,8 +86,6 @@ class MarkAssignments(CythonTransform): ...@@ -82,8 +86,6 @@ class MarkAssignments(CythonTransform):
'+', '+',
sequence.args[0], sequence.args[0],
sequence.args[2])) sequence.args[2]))
elif function.name == 'reversed' and len(sequence.args) == 1:
sequence = sequence.args[0]
if not is_special: if not is_special:
# A for-loop basically translates to subsequent calls to # A for-loop basically translates to subsequent calls to
......
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