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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a0057c6f
Commit
a0057c6f
authored
Mar 25, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loop semantics are STILL wrong, as were some T203 doctests
parent
253ed803
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
28 deletions
+89
-28
tests/run/range_optimisation_T203.pyx
tests/run/range_optimisation_T203.pyx
+89
-28
No files found.
tests/run/range_optimisation_T203.pyx
View file @
a0057c6f
__doc__
=
u"""
>>> test_var(10, 5)
>>> for_from_range(5, 10)
range(5)
at 0
at 1
at 2
at 3
at 4
range(5, 10)
at 5
at 6
at 7
at 8
at 9
range(5, 10, 2)
at 5
at 7
at 9
9
>>> for_from_bound_reassignment(5, 1)
at 0
at 1
at 2
at 3
at 4
5
>>> for_from_step_reassignment(15, 5, 2)
at 0
at 5
at 10
15
>>> for_from_target_reassignment(10, 2)
at 0
at 1
at 3
at 7
15
>>> for_from_py_target_reassignment(10, 2)
at 0
at 1
at 3
at 7
15
>>> for_in_target_reassignment(10, 2)
at 0
at 1
at 2
at 3
at 4
at 5
at 6
at 7
at 8
at 9
18
>>> test_func(5)
get_bound(5)
at 0
...
...
@@ -14,47 +61,61 @@ at 2
at 3
at 4
5
>>> test_f()
9
>>> f()
g called
0
1
2
2
"""
def
for_from_range
(
a
,
b
):
cdef
int
i
print
"range(%s)"
%
a
for
i
in
range
(
a
):
print
"at"
,
i
print
"range(%s, %s)"
%
(
a
,
b
)
for
i
in
range
(
a
,
b
):
print
"at"
,
i
print
"range(%s, %s, %s)"
%
(
a
,
b
,
2
)
for
i
in
range
(
a
,
b
,
2
):
print
"at"
,
i
return
i
cdef
int
get_bound
(
int
m
):
print
"get_bound(%s)"
%
m
return
m
def
test_var
(
int
n
,
int
m
):
def
for_from_bound_reassignment
(
int
bound
,
int
fake_bound
):
cdef
int
i
for
i
from
0
<=
i
<
n
:
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
n
=
m
bound
=
fake_bound
return
i
def
test_func
(
int
n
):
def
for_from_step_reassignment
(
int
bound
,
int
step
,
int
fake_step
):
cdef
int
i
for
i
from
0
<=
i
<
get_bound
(
n
)
:
for
i
from
0
<=
i
<
bound
by
step
:
print
"at"
,
i
step
=
fake_step
return
i
def
test_f
(
):
cdef
int
i
,
n
n
=
10
for
i
in
range
(
n
):
if
i
==
5
:
n
*=
2
print
i
def
for_from_target_reassignment
(
int
bound
,
int
factor
):
cdef
int
i
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
i
*=
factor
return
i
cdef
int
g
():
print
"g called"
return
3
def
for_from_py_target_reassignment
(
int
bound
,
int
factor
):
cdef
object
i
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
i
*=
factor
return
i
def
f
():
cdef
int
i
=
-
1
for
i
in
range
(
g
()):
print
i
print
i
def
for_in_target_reassignment
(
int
bound
,
int
factor
):
cdef
int
i
for
i
in
range
(
bound
):
print
"at"
,
i
i
*=
factor
return
i
def
test_func
(
int
n
):
cdef
int
i
for
i
from
0
<=
i
<
get_bound
(
n
):
print
"at"
,
i
return
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