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
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):
...
@@ -2055,49 +2055,48 @@ class DefNode(FuncDefNode):
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
# now fill up the required arguments with values from the kw dict
# now fill up the required arguments with values from the kw dict
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
last_required_arg
=
-
1
needs_break
=
False
for
i
,
arg
in
enumerate
(
all_args
):
for
i
,
arg
in
enumerate
(
all_args
):
if
i
<=
max_positional_args
:
if
not
arg
.
default
:
if
self
.
star_arg
and
i
==
max_positional_args
:
last_required_arg
=
i
code
.
putln
(
'default:'
)
if
last_required_arg
>=
0
:
else
:
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
code
.
putln
(
'case %2d:'
%
i
)
for
i
,
arg
in
enumerate
(
all_args
[:
last_required_arg
+
1
]):
if
arg
.
default
:
if
i
<=
max_positional_args
:
# handled in ParseOptionalKeywords() below
if
self
.
star_arg
and
i
==
max_positional_args
:
needs_break
=
True
code
.
putln
(
'default:'
)
continue
else
:
else
:
code
.
putln
(
'case %2d:'
%
i
)
needs_break
=
False
if
arg
.
default
:
code
.
putln
(
'values[%d] = PyDict_GetItem(%s, %s);'
%
(
# handled in ParseOptionalKeywords() below
i
,
Naming
.
kwds_cname
,
arg
.
name_entry
.
pystring_cname
))
continue
if
i
<
min_positional_args
:
code
.
putln
(
'values[%d] = PyDict_GetItem(%s, %s);'
%
(
code
.
putln
(
'if (likely(values[%d])) kw_args--;'
%
i
);
i
,
Naming
.
kwds_cname
,
arg
.
name_entry
.
pystring_cname
))
if
i
==
0
:
if
i
<
min_positional_args
:
# special case: we know arg 0 is missing
code
.
putln
(
'if (likely(values[%d])) kw_args--;'
%
i
);
code
.
put
(
'else '
)
if
i
==
0
:
code
.
put_goto
(
argtuple_error_label
)
# 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
:
else
:
# print the correct number of values (args or
code
.
putln
(
'if (values[%d]) kw_args--;'
%
i
);
# kwargs) that were passed into positional
if
arg
.
kw_only
and
not
arg
.
default
:
# arguments up to this point
code
.
putln
(
'else {'
)
code
.
putln
(
'else {'
)
code
.
put
(
'__Pyx_RaiseKeywordRequired("%s", %s); '
%
(
code
.
put
(
'__Pyx_RaiseArgtupleInvalid("%s", %d, %d, %d, %d); '
%
(
self
.
name
.
utf8encode
(),
arg
.
name_entry
.
pystring_cname
))
self
.
name
.
utf8encode
(),
has_fixed_positional_count
,
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
min_positional_args
,
max_positional_args
,
i
))
code
.
putln
(
'}'
)
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
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 (unlikely(kw_args > 0)) {'
)
code
.
putln
(
'if (unlikely(kw_args > 0)) {'
)
# non-positional kw args left in dict: default args, **kwargs or error
# 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