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
57d4d305
Commit
57d4d305
authored
Nov 01, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid generating inlined keyword unpacking code when signature has only optional arguments
parent
4cd97c23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
41 deletions
+40
-41
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+40
-41
No files found.
Cython/Compiler/Nodes.py
View file @
57d4d305
...
...
@@ -2055,49 +2055,48 @@ class DefNode(FuncDefNode):
code
.
putln
(
'}'
)
# now fill up the required arguments with values from the kw dict
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
needs_break
=
False
last_required_arg
=
-
1
for
i
,
arg
in
enumerate
(
all_args
):
if
i
<=
max_positional_args
:
if
self
.
star_arg
and
i
==
max_positional_args
:
code
.
putln
(
'default:'
)
else
:
code
.
putln
(
'case %2d:'
%
i
)
if
arg
.
default
:
# handled in ParseOptionalKeywords() below
needs_break
=
True
continue
else
:
needs_break
=
False
code
.
putln
(
'values[%d] = PyDict_GetItem(%s, %s);'
%
(
i
,
Naming
.
kwds_cname
,
arg
.
name_entry
.
pystring_cname
))
if
i
<
min_positional_args
:
code
.
putln
(
'if (likely(values[%d])) kw_args--;'
%
i
);
if
i
==
0
:
# special case: we know arg 0 is missing
code
.
put
(
'else '
)
code
.
put_goto
(
argtuple_error_label
)
if
not
arg
.
default
:
last_required_arg
=
i
if
last_required_arg
>=
0
:
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
for
i
,
arg
in
enumerate
(
all_args
[:
last_required_arg
+
1
]):
if
i
<=
max_positional_args
:
if
self
.
star_arg
and
i
==
max_positional_args
:
code
.
putln
(
'default:'
)
else
:
code
.
putln
(
'case %2d:'
%
i
)
if
arg
.
default
:
# handled in ParseOptionalKeywords() below
continue
code
.
putln
(
'values[%d] = PyDict_GetItem(%s, %s);'
%
(
i
,
Naming
.
kwds_cname
,
arg
.
name_entry
.
pystring_cname
))
if
i
<
min_positional_args
:
code
.
putln
(
'if (likely(values[%d])) kw_args--;'
%
i
);
if
i
==
0
:
# special case: we know arg 0 is missing
code
.
put
(
'else '
)
code
.
put_goto
(
argtuple_error_label
)
else
:
# print the correct number of values (args or
# kwargs) that were passed into positional
# arguments up to this point
code
.
putln
(
'else {'
)
code
.
put
(
'__Pyx_RaiseArgtupleInvalid("%s", %d, %d, %d, %d); '
%
(
self
.
name
.
utf8encode
(),
has_fixed_positional_count
,
min_positional_args
,
max_positional_args
,
i
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
else
:
# print the correct number of values (args or
# kwargs) that were passed into positional
# arguments up to this point
code
.
putln
(
'else {'
)
code
.
put
(
'__Pyx_RaiseArgtupleInvalid("%s", %d, %d, %d, %d); '
%
(
self
.
name
.
utf8encode
(),
has_fixed_positional_count
,
min_positional_args
,
max_positional_args
,
i
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
else
:
code
.
putln
(
'if (values[%d]) kw_args--;'
%
i
);
if
arg
.
kw_only
and
not
arg
.
default
:
code
.
putln
(
'else {'
)
code
.
put
(
'__Pyx_RaiseKeywordRequired("%s", %s); '
%
(
self
.
name
.
utf8encode
(),
arg
.
name_entry
.
pystring_cname
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
if
needs_break
:
code
.
putln
(
'break;'
)
code
.
putln
(
'}'
)
code
.
putln
(
'if (values[%d]) kw_args--;'
%
i
);
if
arg
.
kw_only
and
not
arg
.
default
:
code
.
putln
(
'else {'
)
code
.
put
(
'__Pyx_RaiseKeywordRequired("%s", %s); '
%
(
self
.
name
.
utf8encode
(),
arg
.
name_entry
.
pystring_cname
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
putln
(
'if (unlikely(kw_args > 0)) {'
)
# non-positional kw args left in dict: default args, **kwargs or error
...
...
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