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
25920642
Commit
25920642
authored
Apr 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent redundant type checks for None values, especially in cascaded assignments
parent
eb1e7173
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-1
tests/run/unpack.pyx
tests/run/unpack.pyx
+4
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
25920642
...
@@ -699,7 +699,7 @@ class ExprNode(Node):
...
@@ -699,7 +699,7 @@ class ExprNode(Node):
else
:
else
:
src
=
CoerceToPyTypeNode
(
src
,
env
,
type
=
dst_type
)
src
=
CoerceToPyTypeNode
(
src
,
env
,
type
=
dst_type
)
if
not
src
.
type
.
subtype_of
(
dst_type
):
if
not
src
.
type
.
subtype_of
(
dst_type
):
if
not
isinstance
(
src
,
NoneNode
)
:
if
src
.
constant_result
is
not
None
:
src
=
PyTypeTestNode
(
src
,
dst_type
,
env
)
src
=
PyTypeTestNode
(
src
,
dst_type
,
env
)
elif
src
.
type
.
is_pyobject
:
elif
src
.
type
.
is_pyobject
:
src
=
CoerceFromPyTypeNode
(
dst_type
,
src
,
env
)
src
=
CoerceFromPyTypeNode
(
dst_type
,
src
,
env
)
...
@@ -10458,6 +10458,7 @@ class ProxyNode(CoercionNode):
...
@@ -10458,6 +10458,7 @@ class ProxyNode(CoercionNode):
def
__init__
(
self
,
arg
):
def
__init__
(
self
,
arg
):
super
(
ProxyNode
,
self
).
__init__
(
arg
)
super
(
ProxyNode
,
self
).
__init__
(
arg
)
self
.
constant_result
=
arg
.
constant_result
self
.
_proxy_type
()
self
.
_proxy_type
()
def
analyse_expressions
(
self
,
env
):
def
analyse_expressions
(
self
,
env
):
...
@@ -10509,6 +10510,7 @@ class CloneNode(CoercionNode):
...
@@ -10509,6 +10510,7 @@ class CloneNode(CoercionNode):
def
__init__
(
self
,
arg
):
def
__init__
(
self
,
arg
):
CoercionNode
.
__init__
(
self
,
arg
)
CoercionNode
.
__init__
(
self
,
arg
)
self
.
constant_result
=
arg
.
constant_result
if
hasattr
(
arg
,
'type'
):
if
hasattr
(
arg
,
'type'
):
self
.
type
=
arg
.
type
self
.
type
=
arg
.
type
self
.
result_ctype
=
arg
.
result_ctype
self
.
result_ctype
=
arg
.
result_ctype
...
...
tests/run/unpack.pyx
View file @
25920642
# mode: run
# mode: run
# tag: sequence_unpacking
# tag: sequence_unpacking
import
cython
_set
=
set
_set
=
set
def
_it
(
N
):
def
_it
(
N
):
...
@@ -365,6 +367,7 @@ def unpack_many_int(it):
...
@@ -365,6 +367,7 @@ def unpack_many_int(it):
return
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
k
,
l
return
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
k
,
l
@
cython
.
test_fail_if_path_exists
(
'//PyTypeTestNode'
)
def
unpack_literal_none_to_builtin_type
():
def
unpack_literal_none_to_builtin_type
():
"""
"""
>>> unpack_literal_none_to_builtin_type()
>>> unpack_literal_none_to_builtin_type()
...
@@ -379,6 +382,7 @@ cdef class ExtType:
...
@@ -379,6 +382,7 @@ cdef class ExtType:
pass
pass
@
cython
.
test_fail_if_path_exists
(
'//PyTypeTestNode'
)
def
unpack_literal_none_to_exttype
():
def
unpack_literal_none_to_exttype
():
"""
"""
>>> unpack_literal_none_to_exttype()
>>> unpack_literal_none_to_exttype()
...
...
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