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
Kirill Smelkov
cython
Commits
8ef81da5
Commit
8ef81da5
authored
Jan 01, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support non-trivial counter targets for enumerate() loop optimisation
parent
cae65475
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+0
-3
tests/run/enumerate_T316.pyx
tests/run/enumerate_T316.pyx
+27
-0
No files found.
Cython/Compiler/Optimize.py
View file @
8ef81da5
...
...
@@ -523,9 +523,6 @@ class IterationTransform(Visitor.EnvTransform):
if
len
(
targets
)
!=
2
:
# leave this untouched for now
return
node
if
not
isinstance
(
targets
[
0
],
ExprNodes
.
NameNode
):
# leave this untouched for now
return
node
enumerate_target
,
iterable_target
=
targets
counter_type
=
enumerate_target
.
type
...
...
tests/run/enumerate_T316.pyx
View file @
8ef81da5
...
...
@@ -14,6 +14,19 @@ def go_py_enumerate():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
py_enumerate_list_index_target
():
"""
>>> py_enumerate_list_index_target()
[0] 1
[1] 2
[2] 3
[3] 4
"""
target
=
[
None
]
for
target
[
0
],
k
in
enumerate
(
range
(
1
,
5
)):
print
target
,
k
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_py_enumerate_start
():
"""
...
...
@@ -39,6 +52,20 @@ def go_c_enumerate():
for
i
,
k
in
enumerate
(
range
(
1
,
5
)):
print
i
,
k
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
c_enumerate_carray_target
():
"""
>>> c_enumerate_carray_target()
0 1
1 2
2 3
3 4
"""
cdef
int
k
cdef
int
i
[
1
]
for
i
[
0
],
k
in
enumerate
(
range
(
1
,
5
)):
print
i
[
0
],
k
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode//NameNode[@name = 'enumerate']"
)
def
go_c_enumerate_step
():
"""
...
...
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