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
371b3568
Commit
371b3568
authored
Dec 01, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strip mult-factor from empty list literals
parent
9ecf58c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+2
-2
tests/run/constant_folding.py
tests/run/constant_folding.py
+11
-0
No files found.
Cython/Compiler/Optimize.py
View file @
371b3568
...
...
@@ -3269,7 +3269,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
sequence_node
=
node
.
operand1
factor
=
node
.
operand2
self
.
_calculate_const
(
factor
)
if
factor
.
constant_result
!=
1
:
if
factor
.
constant_result
!=
1
and
sequence_node
.
args
:
sequence_node
.
mult_factor
=
factor
self
.
visitchildren
(
sequence_node
)
return
sequence_node
...
...
@@ -3278,7 +3278,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
sequence_node
=
node
.
operand2
factor
=
node
.
operand1
self
.
_calculate_const
(
factor
)
if
factor
.
constant_result
!=
1
:
if
factor
.
constant_result
!=
1
and
sequence_node
.
args
:
sequence_node
.
mult_factor
=
factor
self
.
visitchildren
(
sequence_node
)
return
sequence_node
...
...
tests/run/constant_folding.py
View file @
371b3568
...
...
@@ -278,3 +278,14 @@ def for_in_nested_listcomp():
[]
"""
return
[
x
for
x
in
[
1
,
2
,
3
]
for
_
in
[]]
@
cython
.
test_fail_if_path_exists
(
"//ListNode//IntNode"
,
)
def
mult_empty_list
():
"""
>>> mult_empty_list()
[]
"""
return
5
*
[]
*
100
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