Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
d19d6396
Commit
d19d6396
authored
Oct 29, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #442: non-pyobject for-in-loop targets failed with enumerate() optimisation
parent
a2bbb8f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-4
tests/run/enumerate_T316.pyx
tests/run/enumerate_T316.pyx
+5
-5
No files found.
Cython/Compiler/Optimize.py
View file @
d19d6396
...
@@ -236,10 +236,6 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -236,10 +236,6 @@ class IterationTransform(Visitor.VisitorTransform):
if
not
counter_type
.
is_pyobject
and
not
counter_type
.
is_int
:
if
not
counter_type
.
is_pyobject
and
not
counter_type
.
is_int
:
# nothing we can do here, I guess
# nothing we can do here, I guess
return
node
return
node
if
iterable_target
.
type
is
not
PyrexTypes
.
py_object_type
:
# this may need conversion, could be made to work
return
node
temp
=
UtilNodes
.
LetRefNode
(
ExprNodes
.
IntNode
(
enumerate_function
.
pos
,
temp
=
UtilNodes
.
LetRefNode
(
ExprNodes
.
IntNode
(
enumerate_function
.
pos
,
value
=
'0'
,
value
=
'0'
,
...
@@ -276,6 +272,7 @@ class IterationTransform(Visitor.VisitorTransform):
...
@@ -276,6 +272,7 @@ class IterationTransform(Visitor.VisitorTransform):
stats
=
loop_body
)
stats
=
loop_body
)
node
.
target
=
iterable_target
node
.
target
=
iterable_target
node
.
item
=
node
.
item
.
coerce_to
(
iterable_target
.
type
,
self
.
current_scope
)
node
.
iterator
.
sequence
=
enumerate_function
.
arg_tuple
.
args
[
0
]
node
.
iterator
.
sequence
=
enumerate_function
.
arg_tuple
.
args
[
0
]
# recurse into loop to check for further optimisations
# recurse into loop to check for further optimisations
...
...
tests/run/enumerate_T316.pyx
View file @
d19d6396
...
@@ -12,7 +12,7 @@ def go_py_enumerate():
...
@@ -12,7 +12,7 @@ def go_py_enumerate():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
print
i
,
k
#T442
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate
():
def
go_c_enumerate
():
"""
"""
>>> go_c_enumerate()
>>> go_c_enumerate()
...
@@ -25,7 +25,7 @@ def go_c_enumerate():
...
@@ -25,7 +25,7 @@ def go_c_enumerate():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
print
i
,
k
#T442
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate_step
():
def
go_c_enumerate_step
():
"""
"""
>>> go_c_enumerate_step()
>>> go_c_enumerate_step()
...
@@ -97,7 +97,7 @@ def py_enumerate_continue(*t):
...
@@ -97,7 +97,7 @@ def py_enumerate_continue(*t):
continue
continue
print
u"::"
,
i
,
k
print
u"::"
,
i
,
k
# T442
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
empty_c_enumerate
():
def
empty_c_enumerate
():
"""
"""
>>> empty_c_enumerate()
>>> empty_c_enumerate()
...
@@ -132,7 +132,7 @@ def multi_enumerate():
...
@@ -132,7 +132,7 @@ def multi_enumerate():
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
print
a
,
b
,
c
,
d
print
a
,
b
,
c
,
d
# T442
@cython.test_fail_if_path_exists("//SimpleCallNode")
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
)
def
multi_c_enumerate
():
def
multi_c_enumerate
():
"""
"""
>>> multi_c_enumerate()
>>> multi_c_enumerate()
...
@@ -145,7 +145,7 @@ def multi_c_enumerate():
...
@@ -145,7 +145,7 @@ def multi_c_enumerate():
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
for
a
,(
b
,(
c
,
d
))
in
enumerate
(
enumerate
(
enumerate
(
range
(
1
,
5
)))):
print
a
,
b
,
c
,
d
print
a
,
b
,
c
,
d
# T442
@cython.test_fail_if_path_exists("//SimpleCallNode")
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
)
def
convert_target_enumerate
(
L
):
def
convert_target_enumerate
(
L
):
"""
"""
>>> convert_target_enumerate([2,3,5])
>>> convert_target_enumerate([2,3,5])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment