Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-35582: Argument Clinic: Optimize the "all boring objects" case. #11520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Lib/test/clinic.test
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ test_objects_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs
PyObject *a;
PyObject *b = NULL;

if (!_PyArg_UnpackStack(args, nargs, "test_objects_converter",
1, 2,
&a, &b)) {
if (!_PyArg_CheckPositional("test_objects_converter", nargs, 1, 2)) {
goto exit;
}
a = args[0];
if (nargs < 2) {
goto skip_optional;
}
b = args[1];
skip_optional:
return_value = test_objects_converter_impl(module, a, b);

exit:
Expand All @@ -119,7 +123,7 @@ exit:

static PyObject *
test_objects_converter_impl(PyObject *module, PyObject *a, PyObject *b)
/*[clinic end generated code: output=068c25d6ae8cd1ef input=4cbb3d9edd2a36f3]*/
/*[clinic end generated code: output=58009c0e42b4834e input=4cbb3d9edd2a36f3]*/

/*[clinic input]
test_object_converter_subclass_of
Expand Down
11 changes: 7 additions & 4 deletions Modules/_io/clinic/bufferedio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,14 @@ _io__Buffered_truncate(buffered *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
PyObject *pos = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "truncate",
0, 1,
&pos)) {
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
pos = args[0];
skip_optional:
return_value = _io__Buffered_truncate_impl(self, pos);

exit:
Expand Down Expand Up @@ -591,4 +594,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=a85f61f495feff5c input=a9049054013a1b77]*/
/*[clinic end generated code: output=b7f51040defff318 input=a9049054013a1b77]*/
11 changes: 7 additions & 4 deletions Modules/_io/clinic/bytesio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,14 @@ _io_BytesIO_readlines(bytesio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
PyObject *arg = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "readlines",
0, 1,
&arg)) {
if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
arg = args[0];
skip_optional:
return_value = _io_BytesIO_readlines_impl(self, arg);

exit:
Expand Down Expand Up @@ -503,4 +506,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
/*[clinic end generated code: output=5c68eb481fa960bf input=a9049054013a1b77]*/
/*[clinic end generated code: output=a6b47dd7921abfcd input=a9049054013a1b77]*/
11 changes: 7 additions & 4 deletions Modules/_io/clinic/fileio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,14 @@ _io_FileIO_truncate(fileio *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL;
PyObject *posobj = NULL;

if (!_PyArg_UnpackStack(args, nargs, "truncate",
0, 1,
&posobj)) {
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
posobj = args[0];
skip_optional:
return_value = _io_FileIO_truncate_impl(self, posobj);

exit:
Expand Down Expand Up @@ -402,4 +405,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
/*[clinic end generated code: output=4cf4e5f0cd656b11 input=a9049054013a1b77]*/
/*[clinic end generated code: output=b6f327457938d4dd input=a9049054013a1b77]*/
11 changes: 7 additions & 4 deletions Modules/_io/clinic/textio.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,14 @@ _io_TextIOWrapper_truncate(textio *self, PyObject *const *args, Py_ssize_t nargs
PyObject *return_value = NULL;
PyObject *pos = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "truncate",
0, 1,
&pos)) {
if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
pos = args[0];
skip_optional:
return_value = _io_TextIOWrapper_truncate_impl(self, pos);

exit:
Expand Down Expand Up @@ -548,4 +551,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
/*[clinic end generated code: output=8bdd1035bf878d6f input=a9049054013a1b77]*/
/*[clinic end generated code: output=c3d1b2a5d2d2d429 input=a9049054013a1b77]*/
29 changes: 19 additions & 10 deletions Modules/cjkcodecs/clinic/multibytecodec.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,14 @@ _multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, Py
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "read",
0, 1,
&sizeobj)) {
if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
sizeobj = args[0];
skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);

exit:
Expand All @@ -325,11 +328,14 @@ _multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self
PyObject *return_value = NULL;
PyObject *sizeobj = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "readline",
0, 1,
&sizeobj)) {
if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
sizeobj = args[0];
skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);

exit:
Expand All @@ -354,11 +360,14 @@ _multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *sel
PyObject *return_value = NULL;
PyObject *sizehintobj = Py_None;

if (!_PyArg_UnpackStack(args, nargs, "readlines",
0, 1,
&sizehintobj)) {
if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
sizehintobj = args[0];
skip_optional:
return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);

exit:
Expand Down Expand Up @@ -422,4 +431,4 @@ PyDoc_STRVAR(_multibytecodec___create_codec__doc__,

#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
{"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
/*[clinic end generated code: output=2ed7030b28a79029 input=a9049054013a1b77]*/
/*[clinic end generated code: output=bcd6311010557faf input=a9049054013a1b77]*/
20 changes: 10 additions & 10 deletions Modules/clinic/_abc.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 35 additions & 4 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 21 additions & 13 deletions Modules/clinic/_elementtree.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading