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
Boxiang Sun
cython
Commits
fc263982
Commit
fc263982
authored
Mar 20, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch for ticket 203 by Prajwal Suhas P
parent
61521d27
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
7 deletions
+77
-7
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+17
-7
tests/bugs/rangeOptimization_T203.pyx
tests/bugs/rangeOptimization_T203.pyx
+60
-0
No files found.
Cython/Compiler/Nodes.py
View file @
fc263982
...
...
@@ -3967,11 +3967,20 @@ class ForFromStatNode(LoopNode, StatNode):
decop
=
"%s=%s"
%
(
decop
[
0
],
step
)
loopvar_name
=
self
.
loopvar_node
.
result
()
if
from_range
:
temp_range_bound
=
code
.
funcstate
.
allocate_temp
(
self
.
bound2
.
type
,
manage_ref
=
False
)
code
.
putln
(
"%s = %s;"
%
(
temp_range_bound
,
self
.
bound2
.
result
()))
# Skip the loop entirely (and avoid assigning to the loopvar) if
# the loop is empty:
code
.
putln
(
"if (%s%s %s %s) {"
%
(
self
.
bound1
.
result
(),
offset
,
self
.
relation2
,
self
.
bound2
.
result
()
self
.
bound1
.
result
(),
offset
,
self
.
relation2
,
temp_range_bound
))
code
.
putln
(
"for (%s = %s%s; %s %s %s; %s%s) {"
%
(
loopvar_name
,
self
.
bound1
.
result
(),
offset
,
loopvar_name
,
self
.
relation2
,
temp_range_bound
,
loopvar_name
,
incop
))
else
:
code
.
putln
(
"for (%s = %s%s; %s %s %s; %s%s) {"
%
(
loopvar_name
,
...
...
@@ -3988,6 +3997,7 @@ class ForFromStatNode(LoopNode, StatNode):
code
.
putln
(
"} %s%s;"
%
(
loopvar_name
,
decop
))
# End the outer if statement:
code
.
putln
(
"} /* end if */"
)
code
.
funcstate
.
release_temp
(
temp_range_bound
)
else
:
code
.
putln
(
"}"
)
break_label
=
code
.
break_label
...
...
tests/bugs/rangeOptimization_T203.pyx
0 → 100644
View file @
fc263982
__doc__
=
u"""
>>> test_var(10, 5)
at 0
at 1
at 2
at 3
at 4
5
>>> test_func(5)
get_bound(5)
at 0
at 1
at 2
at 3
at 4
5
>>> test_f()
9
>>> f()
g called
0
1
2
2
"""
cdef
int
get_bound
(
int
m
):
print
"get_bound(%s)"
%
m
return
m
def
test_var
(
int
n
,
int
m
):
cdef
int
i
for
i
from
0
<=
i
<
n
:
print
"at"
,
i
n
=
m
return
i
def
test_func
(
int
n
):
cdef
int
i
for
i
from
0
<=
i
<
get_bound
(
n
):
print
"at"
,
i
return
i
def
test_f
():
cdef
int
i
,
n
n
=
10
for
i
in
range
(
n
):
if
i
==
5
:
n
*=
2
print
i
cdef
int
g
():
print
"g called"
return
3
def
f
():
cdef
int
i
for
i
in
range
(
g
()):
print
i
print
i
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