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
00e94093
Commit
00e94093
authored
Sep 25, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged 0.17 branch back into master
parents
6d41b480
e6d53b23
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+11
-19
tests/run/dict_iter_unpack.pyx
tests/run/dict_iter_unpack.pyx
+18
-0
No files found.
Cython/Compiler/Nodes.py
View file @
00e94093
...
...
@@ -5330,24 +5330,21 @@ class DictIterationNextNode(Node):
type
=
PyrexTypes
.
c_bint_type
)
def
analyse_expressions
(
self
,
env
):
import
Util
Nodes
import
Expr
Nodes
self
.
dict_obj
.
analyse_types
(
env
)
self
.
expected_size
.
analyse_types
(
env
)
if
self
.
pos_index_var
:
self
.
pos_index_var
.
analyse_types
(
env
)
if
self
.
key_target
:
self
.
key_target
.
analyse_target_types
(
env
)
self
.
key_ref
=
UtilNodes
.
ResultRefNode
(
pos
=
self
.
key_target
.
pos
,
is_temp
=
True
,
type
=
PyrexTypes
.
py_object_type
)
self
.
key_ref
=
ExprNodes
.
TempNode
(
self
.
key_target
.
pos
,
PyrexTypes
.
py_object_type
)
self
.
coerced_key_var
=
self
.
key_ref
.
coerce_to
(
self
.
key_target
.
type
,
env
)
if
self
.
value_target
:
self
.
value_target
.
analyse_target_types
(
env
)
self
.
value_ref
=
UtilNodes
.
ResultRefNode
(
pos
=
self
.
value_target
.
pos
,
is_temp
=
True
,
type
=
PyrexTypes
.
py_object_type
)
self
.
value_ref
=
ExprNodes
.
TempNode
(
self
.
value_target
.
pos
,
type
=
PyrexTypes
.
py_object_type
)
self
.
coerced_value_var
=
self
.
value_ref
.
coerce_to
(
self
.
value_target
.
type
,
env
)
if
self
.
tuple_target
:
self
.
tuple_target
.
analyse_target_types
(
env
)
self
.
tuple_ref
=
UtilNodes
.
ResultRefNode
(
pos
=
self
.
tuple_target
.
pos
,
is_temp
=
True
,
type
=
PyrexTypes
.
py_object_type
)
self
.
tuple_ref
=
ExprNodes
.
TempNode
(
self
.
tuple_target
.
pos
,
PyrexTypes
.
py_object_type
)
self
.
coerced_tuple_var
=
self
.
tuple_ref
.
coerce_to
(
self
.
tuple_target
.
type
,
env
)
self
.
is_dict_flag
.
analyse_types
(
env
)
...
...
@@ -5366,10 +5363,9 @@ class DictIterationNextNode(Node):
if
target
is
None
:
addr
=
'NULL'
else
:
temp
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
py_object_type
,
True
)
var
.
result_code
=
temp
assignments
.
append
((
temp
,
result
,
target
))
addr
=
'&%s'
%
temp
assignments
.
append
((
var
,
result
,
target
))
var
.
allocate
(
code
)
addr
=
'&%s'
%
var
.
result
()
temp_addresses
.
append
(
addr
)
result_temp
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
False
)
...
...
@@ -5388,17 +5384,13 @@ class DictIterationNextNode(Node):
code
.
funcstate
.
release_temp
(
result_temp
)
# evaluate all coercions before the assignments
for
temp
,
result
,
target
in
assignments
:
code
.
put_gotref
(
temp
)
for
var
,
result
,
target
in
assignments
:
code
.
put_gotref
(
var
.
result
()
)
result
.
generate_evaluation_code
(
code
)
if
not
result
.
type
.
is_pyobject
:
code
.
put_decref_clear
(
temp
,
PyrexTypes
.
py_object_type
)
code
.
funcstate
.
release_temp
(
temp
)
for
temp
,
result
,
target
in
assignments
:
for
var
,
result
,
target
in
assignments
:
target
.
generate_assignment_code
(
result
,
code
)
if
result
.
type
.
is_pyobject
:
code
.
funcstate
.
release_temp
(
temp
)
var
.
release
(
code
)
def
ForStatNode
(
pos
,
**
kw
):
if
'iterator'
in
kw
:
...
...
tests/run/dict_iter_unpack.pyx
0 → 100644
View file @
00e94093
# mode: run
# tag: dictiter
def
iteritems_unpack
(
dict
the_dict
):
"""
>>> d = {(1,2): (3,4), (5,6): (7,8)}
>>> iteritems_unpack(d)
[(1, 2, 3, 4), (5, 6, 7, 8)]
"""
return
sorted
([
(
a
,
b
,
c
,
d
)
for
(
a
,
b
),
(
c
,
d
)
in
the_dict
.
iteritems
()
])
def
itervalues_unpack
(
dict
the_dict
):
"""
>>> d = {1: (3,4), 2: (7,8)}
>>> itervalues_unpack(d)
[(3, 4), (7, 8)]
"""
return
[(
a
,
b
)
for
a
,
b
in
the_dict
.
itervalues
()
]
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