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
7b7094c3
Commit
7b7094c3
authored
Oct 28, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't bother testing the tuple type twice in the critical path.
parent
3fc27935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+12
-3
No files found.
Cython/Compiler/Nodes.py
View file @
7b7094c3
...
...
@@ -1925,7 +1925,7 @@ class DefNode(FuncDefNode):
positional_args
,
kw_only_args
,
argtuple_error_label
,
code
)
# --- optimised code when we do not receive any keyword arguments
if
min_positional_args
>
0
or
min_positional_args
==
max_positional_args
:
if
(
self
.
num_required_kw_args
and
min_positional_args
>
0
)
or
min_positional_args
==
max_positional_args
:
# Python raises arg tuple related errors first, so we must
# check the length here
if
min_positional_args
==
max_positional_args
and
not
self
.
star_arg
:
...
...
@@ -1951,6 +1951,7 @@ class DefNode(FuncDefNode):
len
(
positional_args
)
+
i
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
break
elif
min_positional_args
==
max_positional_args
:
# parse the exact number of positional arguments from the
# args tuple
...
...
@@ -1958,12 +1959,14 @@ class DefNode(FuncDefNode):
for
i
,
arg
in
enumerate
(
positional_args
):
item
=
"PyTuple_GET_ITEM(%s, %d)"
%
(
Naming
.
args_cname
,
i
)
self
.
generate_arg_assignment
(
arg
,
item
,
code
)
else
:
# parse the positional arguments from the variable length
# args tuple
code
.
putln
(
'} else {'
)
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
code
.
putln
(
'default:'
)
if
self
.
star_arg
:
code
.
putln
(
'default:'
)
reversed_args
=
list
(
enumerate
(
positional_args
))[::
-
1
]
for
i
,
arg
in
reversed_args
:
if
i
>=
min_positional_args
-
1
:
...
...
@@ -1973,7 +1976,13 @@ class DefNode(FuncDefNode):
code
.
put
(
'case %2d: '
%
(
i
+
1
))
item
=
"PyTuple_GET_ITEM(%s, %d)"
%
(
Naming
.
args_cname
,
i
)
self
.
generate_arg_assignment
(
arg
,
item
,
code
)
if
not
self
.
star_arg
:
if
self
.
star_arg
:
if
min_positional_args
:
code
.
putln
(
'break;'
)
for
i
in
range
(
min_positional_args
-
1
,
-
1
,
-
1
):
code
.
putln
(
'case %2d:'
%
i
)
code
.
put_goto
(
argtuple_error_label
)
else
:
if
min_positional_args
==
0
:
code
.
put
(
'case 0: '
)
code
.
putln
(
'break;'
)
...
...
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