diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-01-17 00:35:17 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-01-17 00:35:17 (GMT) |
commit | 259f0e4437ed30036578aba822560feb531b7735 (patch) | |
tree | 2ed9ead4992b791c76e1d52e0db3d1cd0516ec11 /Objects/clinic | |
parent | 0c8c3893ae29fab8ce9db0c2f5b52acbe89032e1 (diff) | |
download | cpython-259f0e4437ed30036578aba822560feb531b7735.zip cpython-259f0e4437ed30036578aba822560feb531b7735.tar.gz cpython-259f0e4437ed30036578aba822560feb531b7735.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 only positional arguments.
Diffstat (limited to 'Objects/clinic')
-rw-r--r-- | Objects/clinic/bytearrayobject.c.h | 52 | ||||
-rw-r--r-- | Objects/clinic/bytesobject.c.h | 22 | ||||
-rw-r--r-- | Objects/clinic/unicodeobject.c.h | 52 |
3 files changed, 87 insertions, 39 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index 4ab4329..3e39e9a 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -88,22 +88,26 @@ PyDoc_STRVAR(bytearray_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__}, + {"maketrans", (PyCFunction)bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytearray_maketrans(void *null, PyObject *args) +bytearray_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", &frm, &to)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = bytearray_maketrans_impl(&frm, &to); exit: @@ -133,24 +137,28 @@ PyDoc_STRVAR(bytearray_replace__doc__, "replaced."); #define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__}, + {"replace", (PyCFunction)bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytearray_replace(PyByteArrayObject *self, PyObject *args) +bytearray_replace(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = bytearray_replace_impl(self, &old, &new, count); exit: @@ -310,22 +318,26 @@ PyDoc_STRVAR(bytearray_insert__doc__, " The item to be inserted."); #define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__}, + {"insert", (PyCFunction)bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); static PyObject * -bytearray_insert(PyByteArrayObject *self, PyObject *args) +bytearray_insert(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t index; int item; - if (!PyArg_ParseTuple(args, "nO&:insert", + if (!_PyArg_ParseStack(args, nargs, "nO&:insert", &index, _getbytevalue, &item)) { goto exit; } + + if (!_PyArg_NoStackKeywords("insert", kwnames)) { + goto exit; + } return_value = bytearray_insert_impl(self, index, item); exit: @@ -387,21 +399,25 @@ PyDoc_STRVAR(bytearray_pop__doc__, "If no index argument is given, will pop the last item."); #define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__}, + {"pop", (PyCFunction)bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); static PyObject * -bytearray_pop(PyByteArrayObject *self, PyObject *args) +bytearray_pop(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t index = -1; - if (!PyArg_ParseTuple(args, "|n:pop", + if (!_PyArg_ParseStack(args, nargs, "|n:pop", &index)) { goto exit; } + + if (!_PyArg_NoStackKeywords("pop", kwnames)) { + goto exit; + } return_value = bytearray_pop_impl(self, index); exit: @@ -673,21 +689,25 @@ PyDoc_STRVAR(bytearray_reduce_ex__doc__, "Return state information for pickling."); #define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__}, + {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); static PyObject * -bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args) +bytearray_reduce_ex(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; int proto = 0; - if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", + if (!_PyArg_ParseStack(args, nargs, "|i:__reduce_ex__", &proto)) { goto exit; } + + if (!_PyArg_NoStackKeywords("__reduce_ex__", kwnames)) { + goto exit; + } return_value = bytearray_reduce_ex_impl(self, proto); exit: @@ -711,4 +731,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=225342a680391b9c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e6c057d1cd7c2496 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index dd1ec91..330cb84 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -318,22 +318,26 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", (PyCFunction)bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytes_maketrans(void *null, PyObject *args) +bytes_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", &frm, &to)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = bytes_maketrans_impl(&frm, &to); exit: @@ -363,24 +367,28 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, + {"replace", (PyCFunction)bytes_replace, METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytes_replace(PyBytesObject *self, PyObject *args) +bytes_replace(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = bytes_replace_impl(self, &old, &new, count); exit: @@ -499,4 +507,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=2dc3c93cfd2dc440 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2b8d3cff7e11045e input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index b2d91b7..d968cbe 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -71,22 +71,26 @@ PyDoc_STRVAR(unicode_center__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_CENTER_METHODDEF \ - {"center", (PyCFunction)unicode_center, METH_VARARGS, unicode_center__doc__}, + {"center", (PyCFunction)unicode_center, METH_FASTCALL, unicode_center__doc__}, static PyObject * unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); static PyObject * -unicode_center(PyObject *self, PyObject *args) +unicode_center(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!PyArg_ParseTuple(args, "n|O&:center", + if (!_PyArg_ParseStack(args, nargs, "n|O&:center", &width, convert_uc, &fillchar)) { goto exit; } + + if (!_PyArg_NoStackKeywords("center", kwnames)) { + goto exit; + } return_value = unicode_center_impl(self, width, fillchar); exit: @@ -419,22 +423,26 @@ PyDoc_STRVAR(unicode_ljust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_LJUST_METHODDEF \ - {"ljust", (PyCFunction)unicode_ljust, METH_VARARGS, unicode_ljust__doc__}, + {"ljust", (PyCFunction)unicode_ljust, METH_FASTCALL, unicode_ljust__doc__}, static PyObject * unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); static PyObject * -unicode_ljust(PyObject *self, PyObject *args) +unicode_ljust(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!PyArg_ParseTuple(args, "n|O&:ljust", + if (!_PyArg_ParseStack(args, nargs, "n|O&:ljust", &width, convert_uc, &fillchar)) { goto exit; } + + if (!_PyArg_NoStackKeywords("ljust", kwnames)) { + goto exit; + } return_value = unicode_ljust_impl(self, width, fillchar); exit: @@ -566,24 +574,28 @@ PyDoc_STRVAR(unicode_replace__doc__, "replaced."); #define UNICODE_REPLACE_METHODDEF \ - {"replace", (PyCFunction)unicode_replace, METH_VARARGS, unicode_replace__doc__}, + {"replace", (PyCFunction)unicode_replace, METH_FASTCALL, unicode_replace__doc__}, static PyObject * unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new, Py_ssize_t count); static PyObject * -unicode_replace(PyObject *self, PyObject *args) +unicode_replace(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *old; PyObject *new; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "UU|n:replace", + if (!_PyArg_ParseStack(args, nargs, "UU|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = unicode_replace_impl(self, old, new, count); exit: @@ -599,22 +611,26 @@ PyDoc_STRVAR(unicode_rjust__doc__, "Padding is done using the specified fill character (default is a space)."); #define UNICODE_RJUST_METHODDEF \ - {"rjust", (PyCFunction)unicode_rjust, METH_VARARGS, unicode_rjust__doc__}, + {"rjust", (PyCFunction)unicode_rjust, METH_FASTCALL, unicode_rjust__doc__}, static PyObject * unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); static PyObject * -unicode_rjust(PyObject *self, PyObject *args) +unicode_rjust(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t width; Py_UCS4 fillchar = ' '; - if (!PyArg_ParseTuple(args, "n|O&:rjust", + if (!_PyArg_ParseStack(args, nargs, "n|O&:rjust", &width, convert_uc, &fillchar)) { goto exit; } + + if (!_PyArg_NoStackKeywords("rjust", kwnames)) { + goto exit; + } return_value = unicode_rjust_impl(self, width, fillchar); exit: @@ -799,23 +815,27 @@ PyDoc_STRVAR(unicode_maketrans__doc__, "must be a string, whose characters will be mapped to None in the result."); #define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__}, + {"maketrans", (PyCFunction)unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); static PyObject * -unicode_maketrans(void *null, PyObject *args) +unicode_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *x; PyObject *y = NULL; PyObject *z = NULL; - if (!PyArg_ParseTuple(args, "O|UU:maketrans", + if (!_PyArg_ParseStack(args, nargs, "O|UU:maketrans", &x, &y, &z)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = unicode_maketrans_impl(x, y, z); exit: @@ -930,4 +950,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) { return unicode_sizeof_impl(self); } -/*[clinic end generated code: output=3b9b1e1f71ba3b00 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=eb6a3ae361a1a379 input=a9049054013a1b77]*/ |