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
47a94155
Commit
47a94155
authored
Oct 03, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement None check removal for binary operations on builtin types
parent
ec9e1b3c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-0
tests/run/cf_none.pyx
tests/run/cf_none.pyx
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
47a94155
...
...
@@ -6741,6 +6741,16 @@ class NumBinopNode(BinopNode):
else
:
return
None
def
may_be_none
(
self
):
type1
=
self
.
operand1
.
type
type2
=
self
.
operand2
.
type
if
type1
and
type1
.
is_builtin_type
and
type2
and
type2
.
is_builtin_type
:
# XXX: I can't think of any case where a binary operation
# on builtin types evaluates to None - add a special case
# here if there is one.
return
False
return
super
(
NumBinopNode
,
self
).
may_be_none
()
def
get_constant_c_result_code
(
self
):
value1
=
self
.
operand1
.
get_constant_c_result_code
()
value2
=
self
.
operand2
.
get_constant_c_result_code
()
...
...
tests/run/cf_none.pyx
View file @
47a94155
...
...
@@ -114,7 +114,7 @@ def self_dependency_none(int x):
a
,
b
=
b
,
a
return
b
.
get
(
2
)
#
@cython.test_fail_if_path_exists('//NoneCheckNode')
@
cython
.
test_fail_if_path_exists
(
'//NoneCheckNode'
)
def
in_place_op
():
vals
=
[
0
]
vals
+=
[
1
]
...
...
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