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
8c9ab4a0
Commit
8c9ab4a0
authored
Jan 15, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid generating lots of unused iteration fallback code for tuple unpacking
parent
d929ac08
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+21
-12
No files found.
Cython/Compiler/ExprNodes.py
View file @
8c9ab4a0
...
@@ -5909,6 +5909,7 @@ class SequenceNode(ExprNode):
...
@@ -5909,6 +5909,7 @@ class SequenceNode(ExprNode):
if
special_unpack
:
if
special_unpack
:
self
.
generate_special_parallel_unpacking_code
(
self
.
generate_special_parallel_unpacking_code
(
code
,
rhs
,
use_loop
=
long_enough_for_a_loop
)
code
,
rhs
,
use_loop
=
long_enough_for_a_loop
)
else
:
code
.
putln
(
"{"
)
code
.
putln
(
"{"
)
self
.
generate_generic_parallel_unpacking_code
(
self
.
generate_generic_parallel_unpacking_code
(
code
,
rhs
,
self
.
unpacked_items
,
use_loop
=
long_enough_for_a_loop
)
code
,
rhs
,
self
.
unpacked_items
,
use_loop
=
long_enough_for_a_loop
)
...
@@ -5921,19 +5922,20 @@ class SequenceNode(ExprNode):
...
@@ -5921,19 +5922,20 @@ class SequenceNode(ExprNode):
self
.
coerced_unpacked_items
[
i
],
code
)
self
.
coerced_unpacked_items
[
i
],
code
)
def
generate_special_parallel_unpacking_code
(
self
,
code
,
rhs
,
use_loop
):
def
generate_special_parallel_unpacking_code
(
self
,
code
,
rhs
,
use_loop
):
tuple_check
=
'likely(PyTuple_CheckExact(%s))'
%
rhs
.
py_result
()
list_check
=
'PyList_CheckExact(%s)'
%
rhs
.
py_result
()
sequence_type_test
=
'1'
sequence_type_test
=
'1'
none_check
=
"likely(%s != Py_None)"
%
rhs
.
py_result
()
if
rhs
.
type
is
list_type
:
if
rhs
.
type
is
list_type
:
sequence_types
=
[
'List'
]
sequence_types
=
[
'List'
]
if
rhs
.
may_be_none
():
if
rhs
.
may_be_none
():
sequence_type_test
=
list
_check
sequence_type_test
=
none
_check
elif
rhs
.
type
is
tuple_type
:
elif
rhs
.
type
is
tuple_type
:
sequence_types
=
[
'Tuple'
]
sequence_types
=
[
'Tuple'
]
if
rhs
.
may_be_none
():
if
rhs
.
may_be_none
():
sequence_type_test
=
tupl
e_check
sequence_type_test
=
non
e_check
else
:
else
:
sequence_types
=
[
'Tuple'
,
'List'
]
sequence_types
=
[
'Tuple'
,
'List'
]
tuple_check
=
'likely(PyTuple_CheckExact(%s))'
%
rhs
.
py_result
()
list_check
=
'PyList_CheckExact(%s)'
%
rhs
.
py_result
()
sequence_type_test
=
"(%s) || (%s)"
%
(
tuple_check
,
list_check
)
sequence_type_test
=
"(%s) || (%s)"
%
(
tuple_check
,
list_check
)
code
.
putln
(
"if (%s) {"
%
sequence_type_test
)
code
.
putln
(
"if (%s) {"
%
sequence_type_test
)
...
@@ -5993,13 +5995,20 @@ class SequenceNode(ExprNode):
...
@@ -5993,13 +5995,20 @@ class SequenceNode(ExprNode):
code
.
putln
(
"#endif"
)
code
.
putln
(
"#endif"
)
rhs
.
generate_disposal_code
(
code
)
rhs
.
generate_disposal_code
(
code
)
if
rhs
.
type
is
tuple_type
:
if
sequence_type_test
==
'1'
:
# if not a tuple: None => save some code by generating the error directly
code
.
putln
(
"}"
)
# all done
code
.
putln
(
"} else if (1) {"
)
elif
rhs
.
type
is
tuple_type
:
# either tuple or None => save some code by generating the error directly
code
.
putln
(
"} else {"
)
code
.
globalstate
.
use_utility_code
(
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"RaiseNoneIterError"
,
"ObjectHandling.c"
))
UtilityCode
.
load_cached
(
"RaiseNoneIterError"
,
"ObjectHandling.c"
))
code
.
putln
(
"__Pyx_RaiseNoneNotIterableError(); %s"
%
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"__Pyx_RaiseNoneNotIterableError(); %s"
%
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"} else"
)
code
.
putln
(
"}"
)
# all done
else
:
code
.
putln
(
"} else {"
)
# needs iteration fallback code
self
.
generate_generic_parallel_unpacking_code
(
code
,
rhs
,
self
.
unpacked_items
,
use_loop
=
use_loop
)
code
.
putln
(
"}"
)
def
generate_generic_parallel_unpacking_code
(
self
,
code
,
rhs
,
unpacked_items
,
use_loop
,
terminate
=
True
):
def
generate_generic_parallel_unpacking_code
(
self
,
code
,
rhs
,
unpacked_items
,
use_loop
,
terminate
=
True
):
code
.
globalstate
.
use_utility_code
(
raise_need_more_values_to_unpack
)
code
.
globalstate
.
use_utility_code
(
raise_need_more_values_to_unpack
)
...
...
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