summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-17 01:21:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-01-17 01:21:47 (GMT)
commit0c4a828cadfccd8b95a39f7930705de75ed5f729 (patch)
tree713eeceb5c63f4324fa83e9603a0284272e9eb58 /Python
parent093119e4eb8424451ef24a5a5a3ce9881d77abd5 (diff)
downloadcpython-0c4a828cadfccd8b95a39f7930705de75ed5f729.zip
cpython-0c4a828cadfccd8b95a39f7930705de75ed5f729.tar.gz
cpython-0c4a828cadfccd8b95a39f7930705de75ed5f729.tar.bz2
Run Argument Clinic: METH_VARARGS=>METH_FASTCALL
Issue #29286. Run Argument Clinic to get the new faster METH_FASTCALL calling convention for functions using "boring" positional arguments. Manually fix _elementtree: _elementtree_XMLParser_doctype() must remain consistent with the clinic code.
Diffstat (limited to 'Python')
-rw-r--r--Python/clinic/bltinmodule.c.h112
-rw-r--r--Python/clinic/import.c.h12
2 files changed, 86 insertions, 38 deletions
diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h
index abf45b8..b52bde2 100644
--- a/Python/clinic/bltinmodule.c.h
+++ b/Python/clinic/bltinmodule.c.h
@@ -189,23 +189,27 @@ PyDoc_STRVAR(builtin_divmod__doc__,
"Return the tuple (x//y, x%y). Invariant: div*y + mod == x.");
#define BUILTIN_DIVMOD_METHODDEF \
- {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__},
+ {"divmod", (PyCFunction)builtin_divmod, METH_FASTCALL, builtin_divmod__doc__},
static PyObject *
builtin_divmod_impl(PyObject *module, PyObject *x, PyObject *y);
static PyObject *
-builtin_divmod(PyObject *module, PyObject *args)
+builtin_divmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *x;
PyObject *y;
- if (!PyArg_UnpackTuple(args, "divmod",
+ if (!_PyArg_UnpackStack(args, nargs, "divmod",
2, 2,
&x, &y)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("divmod", kwnames)) {
+ goto exit;
+ }
return_value = builtin_divmod_impl(module, x, y);
exit:
@@ -225,25 +229,29 @@ PyDoc_STRVAR(builtin_eval__doc__,
"If only globals is given, locals defaults to it.");
#define BUILTIN_EVAL_METHODDEF \
- {"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__},
+ {"eval", (PyCFunction)builtin_eval, METH_FASTCALL, builtin_eval__doc__},
static PyObject *
builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
PyObject *locals);
static PyObject *
-builtin_eval(PyObject *module, PyObject *args)
+builtin_eval(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *source;
PyObject *globals = Py_None;
PyObject *locals = Py_None;
- if (!PyArg_UnpackTuple(args, "eval",
+ if (!_PyArg_UnpackStack(args, nargs, "eval",
1, 3,
&source, &globals, &locals)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("eval", kwnames)) {
+ goto exit;
+ }
return_value = builtin_eval_impl(module, source, globals, locals);
exit:
@@ -263,25 +271,29 @@ PyDoc_STRVAR(builtin_exec__doc__,
"If only globals is given, locals defaults to it.");
#define BUILTIN_EXEC_METHODDEF \
- {"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__},
+ {"exec", (PyCFunction)builtin_exec, METH_FASTCALL, builtin_exec__doc__},
static PyObject *
builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
PyObject *locals);
static PyObject *
-builtin_exec(PyObject *module, PyObject *args)
+builtin_exec(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *source;
PyObject *globals = Py_None;
PyObject *locals = Py_None;
- if (!PyArg_UnpackTuple(args, "exec",
+ if (!_PyArg_UnpackStack(args, nargs, "exec",
1, 3,
&source, &globals, &locals)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("exec", kwnames)) {
+ goto exit;
+ }
return_value = builtin_exec_impl(module, source, globals, locals);
exit:
@@ -318,23 +330,27 @@ PyDoc_STRVAR(builtin_hasattr__doc__,
"This is done by calling getattr(obj, name) and catching AttributeError.");
#define BUILTIN_HASATTR_METHODDEF \
- {"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__},
+ {"hasattr", (PyCFunction)builtin_hasattr, METH_FASTCALL, builtin_hasattr__doc__},
static PyObject *
builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name);
static PyObject *
-builtin_hasattr(PyObject *module, PyObject *args)
+builtin_hasattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
- if (!PyArg_UnpackTuple(args, "hasattr",
+ if (!_PyArg_UnpackStack(args, nargs, "hasattr",
2, 2,
&obj, &name)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("hasattr", kwnames)) {
+ goto exit;
+ }
return_value = builtin_hasattr_impl(module, obj, name);
exit:
@@ -362,25 +378,29 @@ PyDoc_STRVAR(builtin_setattr__doc__,
"setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'");
#define BUILTIN_SETATTR_METHODDEF \
- {"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__},
+ {"setattr", (PyCFunction)builtin_setattr, METH_FASTCALL, builtin_setattr__doc__},
static PyObject *
builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name,
PyObject *value);
static PyObject *
-builtin_setattr(PyObject *module, PyObject *args)
+builtin_setattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
PyObject *value;
- if (!PyArg_UnpackTuple(args, "setattr",
+ if (!_PyArg_UnpackStack(args, nargs, "setattr",
3, 3,
&obj, &name, &value)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("setattr", kwnames)) {
+ goto exit;
+ }
return_value = builtin_setattr_impl(module, obj, name, value);
exit:
@@ -396,23 +416,27 @@ PyDoc_STRVAR(builtin_delattr__doc__,
"delattr(x, \'y\') is equivalent to ``del x.y\'\'");
#define BUILTIN_DELATTR_METHODDEF \
- {"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__},
+ {"delattr", (PyCFunction)builtin_delattr, METH_FASTCALL, builtin_delattr__doc__},
static PyObject *
builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name);
static PyObject *
-builtin_delattr(PyObject *module, PyObject *args)
+builtin_delattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
- if (!PyArg_UnpackTuple(args, "delattr",
+ if (!_PyArg_UnpackStack(args, nargs, "delattr",
2, 2,
&obj, &name)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("delattr", kwnames)) {
+ goto exit;
+ }
return_value = builtin_delattr_impl(module, obj, name);
exit:
@@ -505,24 +529,28 @@ PyDoc_STRVAR(builtin_pow__doc__,
"invoked using the three argument form.");
#define BUILTIN_POW_METHODDEF \
- {"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__},
+ {"pow", (PyCFunction)builtin_pow, METH_FASTCALL, builtin_pow__doc__},
static PyObject *
builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z);
static PyObject *
-builtin_pow(PyObject *module, PyObject *args)
+builtin_pow(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *x;
PyObject *y;
PyObject *z = Py_None;
- if (!PyArg_UnpackTuple(args, "pow",
+ if (!_PyArg_UnpackStack(args, nargs, "pow",
2, 3,
&x, &y, &z)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("pow", kwnames)) {
+ goto exit;
+ }
return_value = builtin_pow_impl(module, x, y, z);
exit:
@@ -542,22 +570,26 @@ PyDoc_STRVAR(builtin_input__doc__,
"On *nix systems, readline is used if available.");
#define BUILTIN_INPUT_METHODDEF \
- {"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__},
+ {"input", (PyCFunction)builtin_input, METH_FASTCALL, builtin_input__doc__},
static PyObject *
builtin_input_impl(PyObject *module, PyObject *prompt);
static PyObject *
-builtin_input(PyObject *module, PyObject *args)
+builtin_input(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *prompt = NULL;
- if (!PyArg_UnpackTuple(args, "input",
+ if (!_PyArg_UnpackStack(args, nargs, "input",
0, 1,
&prompt)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("input", kwnames)) {
+ goto exit;
+ }
return_value = builtin_input_impl(module, prompt);
exit:
@@ -586,23 +618,27 @@ PyDoc_STRVAR(builtin_sum__doc__,
"reject non-numeric types.");
#define BUILTIN_SUM_METHODDEF \
- {"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__},
+ {"sum", (PyCFunction)builtin_sum, METH_FASTCALL, builtin_sum__doc__},
static PyObject *
builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start);
static PyObject *
-builtin_sum(PyObject *module, PyObject *args)
+builtin_sum(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *iterable;
PyObject *start = NULL;
- if (!PyArg_UnpackTuple(args, "sum",
+ if (!_PyArg_UnpackStack(args, nargs, "sum",
1, 2,
&iterable, &start)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("sum", kwnames)) {
+ goto exit;
+ }
return_value = builtin_sum_impl(module, iterable, start);
exit:
@@ -620,24 +656,28 @@ PyDoc_STRVAR(builtin_isinstance__doc__,
"or ...`` etc.");
#define BUILTIN_ISINSTANCE_METHODDEF \
- {"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__},
+ {"isinstance", (PyCFunction)builtin_isinstance, METH_FASTCALL, builtin_isinstance__doc__},
static PyObject *
builtin_isinstance_impl(PyObject *module, PyObject *obj,
PyObject *class_or_tuple);
static PyObject *
-builtin_isinstance(PyObject *module, PyObject *args)
+builtin_isinstance(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *class_or_tuple;
- if (!PyArg_UnpackTuple(args, "isinstance",
+ if (!_PyArg_UnpackStack(args, nargs, "isinstance",
2, 2,
&obj, &class_or_tuple)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("isinstance", kwnames)) {
+ goto exit;
+ }
return_value = builtin_isinstance_impl(module, obj, class_or_tuple);
exit:
@@ -655,27 +695,31 @@ PyDoc_STRVAR(builtin_issubclass__doc__,
"or ...`` etc.");
#define BUILTIN_ISSUBCLASS_METHODDEF \
- {"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__},
+ {"issubclass", (PyCFunction)builtin_issubclass, METH_FASTCALL, builtin_issubclass__doc__},
static PyObject *
builtin_issubclass_impl(PyObject *module, PyObject *cls,
PyObject *class_or_tuple);
static PyObject *
-builtin_issubclass(PyObject *module, PyObject *args)
+builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *cls;
PyObject *class_or_tuple;
- if (!PyArg_UnpackTuple(args, "issubclass",
+ if (!_PyArg_UnpackStack(args, nargs, "issubclass",
2, 2,
&cls, &class_or_tuple)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("issubclass", kwnames)) {
+ goto exit;
+ }
return_value = builtin_issubclass_impl(module, cls, class_or_tuple);
exit:
return return_value;
}
-/*[clinic end generated code: output=66818a69d6d23181 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3234725ef4d8bbf1 input=a9049054013a1b77]*/
diff --git a/Python/clinic/import.c.h b/Python/clinic/import.c.h
index 6ee9120..0165b7c 100644
--- a/Python/clinic/import.c.h
+++ b/Python/clinic/import.c.h
@@ -273,23 +273,27 @@ PyDoc_STRVAR(_imp_create_dynamic__doc__,
"Create an extension module.");
#define _IMP_CREATE_DYNAMIC_METHODDEF \
- {"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_VARARGS, _imp_create_dynamic__doc__},
+ {"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_FASTCALL, _imp_create_dynamic__doc__},
static PyObject *
_imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file);
static PyObject *
-_imp_create_dynamic(PyObject *module, PyObject *args)
+_imp_create_dynamic(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *spec;
PyObject *file = NULL;
- if (!PyArg_UnpackTuple(args, "create_dynamic",
+ if (!_PyArg_UnpackStack(args, nargs, "create_dynamic",
1, 2,
&spec, &file)) {
goto exit;
}
+
+ if (!_PyArg_NoStackKeywords("create_dynamic", kwnames)) {
+ goto exit;
+ }
return_value = _imp_create_dynamic_impl(module, spec, file);
exit:
@@ -365,4 +369,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=5a3f012344950548 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c1d0e65d04114958 input=a9049054013a1b77]*/