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
d5f88aac
Commit
d5f88aac
authored
Dec 18, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup, keep for-range optimisation more local
parent
1f7b40c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
22 deletions
+11
-22
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-7
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+11
-15
No files found.
Cython/Compiler/Nodes.py
View file @
d5f88aac
...
...
@@ -3870,13 +3870,6 @@ class ForFromStatNode(LoopNode, StatNode):
self
.
bound2
.
release_temp
(
env
)
if
self
.
step
is
not
None
:
self
.
step
.
release_temp
(
env
)
def
reanalyse_c_loop
(
self
,
env
):
# only make sure all subnodes have an integer type
self
.
bound1
=
self
.
bound1
.
coerce_to_integer
(
env
)
self
.
bound2
=
self
.
bound2
.
coerce_to_integer
(
env
)
if
self
.
step
is
not
None
:
self
.
step
=
self
.
step
.
coerce_to_integer
(
env
)
def
generate_execution_code
(
self
,
code
):
old_loop_labels
=
code
.
new_loop_labels
()
...
...
Cython/Compiler/Optimize.py
View file @
d5f88aac
...
...
@@ -115,33 +115,31 @@ class IterationTransform(Visitor.VisitorTransform):
else
:
step
=
args
[
2
]
step_pos
=
step
.
pos
if
step
.
constant_result
is
ExprNodes
.
not_a_constant
:
if
not
isinstance
(
step
.
constant_result
,
(
int
,
long
))
:
# cannot determine step direction
return
node
try
:
# FIXME: check how Python handles rounding here, e.g. from float
step_value
=
int
(
step
.
constant_result
)
except
:
step_value
=
step
.
constant_result
if
step_value
==
0
:
# will lead to an error elsewhere
return
node
if
not
isinstance
(
step
,
ExprNodes
.
IntNode
):
step
=
ExprNodes
.
IntNode
(
step_pos
,
value
=
step_value
)
if
step_value
>
0
:
relation1
=
'<='
relation2
=
'<'
elif
step_value
<
0
:
if
step_value
<
0
:
step
.
value
=
-
step_value
relation1
=
'>='
relation2
=
'>'
else
:
return
node
relation1
=
'<='
relation2
=
'<'
if
len
(
args
)
==
1
:
bound1
=
ExprNodes
.
IntNode
(
range_function
.
pos
,
value
=
0
)
bound2
=
args
[
0
]
bound2
=
args
[
0
]
.
coerce_to_integer
(
self
.
current_scope
)
else
:
bound1
=
args
[
0
]
bound2
=
args
[
1
]
bound1
=
args
[
0
].
coerce_to_integer
(
self
.
current_scope
)
bound2
=
args
[
1
].
coerce_to_integer
(
self
.
current_scope
)
step
=
step
.
coerce_to_integer
(
self
.
current_scope
)
for_node
=
Nodes
.
ForFromStatNode
(
node
.
pos
,
...
...
@@ -151,8 +149,6 @@ class IterationTransform(Visitor.VisitorTransform):
step
=
step
,
body
=
node
.
body
,
else_clause
=
node
.
else_clause
,
loopvar_name
=
node
.
target
.
entry
.
cname
)
for_node
.
reanalyse_c_loop
(
self
.
current_scope
)
# for_node.analyse_expressions(self.current_scope)
return
for_node
def
_transform_dict_iteration
(
self
,
node
,
dict_obj
,
keys
,
values
):
...
...
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