mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Argument Clinic: Use METH_FASTCALL for boring positionals
Issue #29286. Use METH_FASTCALL calling convention instead of METH_VARARGS to parse "boring" position arguments. METH_FASTCALL is faster since it avoids the creation of a temporary tuple to pass positional arguments. Replace PyArg_UnpackTuple() with _PyArg_UnpackStack()+_PyArg_NoStackKeywords().
This commit is contained in:
parent
fe54dd8a08
commit
093119e4eb
1 changed files with 25 additions and 9 deletions
|
@ -825,6 +825,22 @@ class CLanguage(Language):
|
||||||
# and nothing but normal objects:
|
# and nothing but normal objects:
|
||||||
# PyArg_UnpackTuple!
|
# PyArg_UnpackTuple!
|
||||||
|
|
||||||
|
if not new_or_init:
|
||||||
|
flags = "METH_FASTCALL"
|
||||||
|
parser_prototype = parser_prototype_fastcall
|
||||||
|
|
||||||
|
parser_definition = parser_body(parser_prototype, normalize_snippet("""
|
||||||
|
if (!_PyArg_UnpackStack(args, nargs, "{name}",
|
||||||
|
{unpack_min}, {unpack_max},
|
||||||
|
{parse_arguments})) {{
|
||||||
|
goto exit;
|
||||||
|
}}
|
||||||
|
|
||||||
|
if ({self_type_check}!_PyArg_NoStackKeywords("{name}", kwnames)) {{
|
||||||
|
goto exit;
|
||||||
|
}}
|
||||||
|
""", indent=4))
|
||||||
|
else:
|
||||||
flags = "METH_VARARGS"
|
flags = "METH_VARARGS"
|
||||||
parser_prototype = parser_prototype_varargs
|
parser_prototype = parser_prototype_varargs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue