summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-01-11 16:01:42 (GMT)
committerGitHub <noreply@github.com>2019-01-11 16:01:42 (GMT)
commit2a39d251f07d4c620e3b9a1848e3d1eb3067be64 (patch)
tree23c1e8e63e57945fab6127d31800b7578795e14b /Tools
parent4fa9591025b6a098f3d6402e5413ee6740ede6c5 (diff)
downloadcpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.zip
cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.gz
cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.bz2
bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520)
Use _PyArg_CheckPositional() and inlined code instead of PyArg_UnpackTuple() and _PyArg_UnpackStack() if all parameters are positional and use the "object" converter.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py40
1 files changed, 0 insertions, 40 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 4087d3f..7f435f1 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -643,18 +643,6 @@ class CLanguage(Language):
f.return_converter.type == 'PyObject *')
positional = parameters and parameters[-1].is_positional_only()
- all_boring_objects = False # yes, this will be false if there are 0 parameters, it's fine
- first_optional = len(parameters)
- for i, p in enumerate(parameters):
- c = p.converter
- if type(c) != object_converter:
- break
- if c.format_unit != 'O':
- break
- if p.default is not unspecified:
- first_optional = min(first_optional, i)
- else:
- all_boring_objects = True
new_or_init = f.kind in (METHOD_NEW, METHOD_INIT)
@@ -827,34 +815,6 @@ class CLanguage(Language):
parser_definition = parser_body(parser_prototype, ' {option_group_parsing}')
- elif positional and all_boring_objects:
- # positional-only, but no option groups,
- # and nothing but normal objects:
- # 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;
- }}
- """, indent=4))
- else:
- flags = "METH_VARARGS"
- parser_prototype = parser_prototype_varargs
-
- parser_definition = parser_body(parser_prototype, normalize_snippet("""
- if (!PyArg_UnpackTuple(args, "{name}",
- {unpack_min}, {unpack_max},
- {parse_arguments})) {{
- goto exit;
- }}
- """, indent=4))
-
elif positional:
if not new_or_init:
# positional-only, but no option groups