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
Gwenaël Samain
cython
Commits
cb2c4269
Commit
cb2c4269
authored
Mar 05, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code cleanup
parent
9ad6182c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+22
-26
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
cb2c4269
...
@@ -242,8 +242,10 @@ class PostParse(CythonTransform):
...
@@ -242,8 +242,10 @@ class PostParse(CythonTransform):
self
.
context
.
nonfatal_error
(
e
)
self
.
context
.
nonfatal_error
(
e
)
return
None
return
None
# support for parallel assignments (a,b = b,a) by splitting them
# Split parallel assignments (a,b = b,a) into separate partial
# into separate assignments that are executed rhs-first
# assignments that are executed rhs-first using temps. This
# optimisation is best applied before type analysis so that known
# types on rhs and lhs can be matched directly.
def
visit_SingleAssignmentNode
(
self
,
node
):
def
visit_SingleAssignmentNode
(
self
,
node
):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
...
@@ -295,7 +297,7 @@ def flatten_parallel_assignments(input, output):
...
@@ -295,7 +297,7 @@ def flatten_parallel_assignments(input, output):
complete_assignments
=
[]
complete_assignments
=
[]
rhs_size
=
len
(
rhs
.
args
)
rhs_size
=
len
(
rhs
.
args
)
lhs_targets
=
[
[]
for
_
in
range
(
rhs_size
)
]
lhs_targets
=
[
[]
for
_
in
x
range
(
rhs_size
)
]
starred_assignments
=
[]
starred_assignments
=
[]
for
lhs
in
input
[:
-
1
]:
for
lhs
in
input
[:
-
1
]:
if
not
lhs
.
is_sequence_constructor
:
if
not
lhs
.
is_sequence_constructor
:
...
@@ -305,7 +307,6 @@ def flatten_parallel_assignments(input, output):
...
@@ -305,7 +307,6 @@ def flatten_parallel_assignments(input, output):
continue
continue
lhs_size
=
len
(
lhs
.
args
)
lhs_size
=
len
(
lhs
.
args
)
starred_targets
=
sum
([
1
for
expr
in
lhs
.
args
if
expr
.
is_starred
])
starred_targets
=
sum
([
1
for
expr
in
lhs
.
args
if
expr
.
is_starred
])
if
starred_targets
:
if
starred_targets
>
1
:
if
starred_targets
>
1
:
error
(
lhs
.
pos
,
"more than 1 starred expression in assignment"
)
error
(
lhs
.
pos
,
"more than 1 starred expression in assignment"
)
output
.
append
([
lhs
,
rhs
])
output
.
append
([
lhs
,
rhs
])
...
@@ -315,14 +316,9 @@ def flatten_parallel_assignments(input, output):
...
@@ -315,14 +316,9 @@ def flatten_parallel_assignments(input, output):
%
(
rhs_size
,
(
rhs_size
!=
1
)
and
's'
or
''
))
%
(
rhs_size
,
(
rhs_size
!=
1
)
and
's'
or
''
))
output
.
append
([
lhs
,
rhs
])
output
.
append
([
lhs
,
rhs
])
continue
continue
elif
starred_targets
==
1
:
map_starred_assignment
(
lhs_targets
,
starred_assignments
,
map_starred_assignment
(
lhs_targets
,
starred_assignments
,
lhs
.
args
,
rhs
.
args
)
lhs
.
args
,
rhs
.
args
)
else
:
if
lhs_size
>
rhs_size
:
error
(
lhs
.
pos
,
"need more than %d value%s to unpack"
%
(
rhs_size
,
(
rhs_size
!=
1
)
and
's'
or
''
))
output
.
append
([
lhs
,
rhs
])
continue
elif
lhs_size
<
rhs_size
:
elif
lhs_size
<
rhs_size
:
error
(
lhs
.
pos
,
"too many values to unpack (expected %d, got %d)"
error
(
lhs
.
pos
,
"too many values to unpack (expected %d, got %d)"
%
(
lhs_size
,
rhs_size
))
%
(
lhs_size
,
rhs_size
))
...
...
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