summaryrefslogtreecommitdiffstats
path: root/Modules/_io/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-08-14 07:52:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-08-14 07:52:18 (GMT)
commit9171a8b4cea3e7b30e4f2c0a989d7f7b8ffabe73 (patch)
tree5cc9c9243ba4ef93902fafdc624e56eab3b15842 /Modules/_io/clinic
parentb6f78c2755489dfcbe4898072ef0cd7dca11ff3d (diff)
downloadcpython-9171a8b4cea3e7b30e4f2c0a989d7f7b8ffabe73.zip
cpython-9171a8b4cea3e7b30e4f2c0a989d7f7b8ffabe73.tar.gz
cpython-9171a8b4cea3e7b30e4f2c0a989d7f7b8ffabe73.tar.bz2
Issue #27574: Decreased an overhead of parsing keyword arguments in functions
implemented with using Argument Clinic.
Diffstat (limited to 'Modules/_io/clinic')
-rw-r--r--Modules/_io/clinic/_iomodule.c.h7
-rw-r--r--Modules/_io/clinic/bufferedio.c.h17
-rw-r--r--Modules/_io/clinic/bytesio.c.h7
-rw-r--r--Modules/_io/clinic/fileio.c.h7
-rw-r--r--Modules/_io/clinic/stringio.c.h7
-rw-r--r--Modules/_io/clinic/textio.c.h17
6 files changed, 36 insertions, 26 deletions
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index ee01cfb..50891c5 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -138,7 +138,8 @@ static PyObject *
_io_open(PyObject *module, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- static char *_keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
+ static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
+ static _PyArg_Parser _parser = {"O|sizzziO:open", _keywords, 0};
PyObject *file;
const char *mode = "r";
int buffering = -1;
@@ -148,7 +149,7 @@ _io_open(PyObject *module, PyObject *args, PyObject *kwargs)
int closefd = 1;
PyObject *opener = Py_None;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sizzziO:open", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&file, &mode, &buffering, &encoding, &errors, &newline, &closefd, &opener)) {
goto exit;
}
@@ -157,4 +158,4 @@ _io_open(PyObject *module, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=ae2facf262cf464e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=14769629391a3130 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bufferedio.c.h b/Modules/_io/clinic/bufferedio.c.h
index c4dfc16..58144a4 100644
--- a/Modules/_io/clinic/bufferedio.c.h
+++ b/Modules/_io/clinic/bufferedio.c.h
@@ -324,11 +324,12 @@ static int
_io_BufferedReader___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedReader", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedReader", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
@@ -356,11 +357,12 @@ static int
_io_BufferedWriter___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedWriter", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedWriter", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
@@ -459,11 +461,12 @@ static int
_io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"raw", "buffer_size", NULL};
+ static const char * const _keywords[] = {"raw", "buffer_size", NULL};
+ static _PyArg_Parser _parser = {"O|n:BufferedRandom", _keywords, 0};
PyObject *raw;
Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|n:BufferedRandom", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&raw, &buffer_size)) {
goto exit;
}
@@ -472,4 +475,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=4f6196c756b880c8 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a956f394ecde4cf9 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/bytesio.c.h b/Modules/_io/clinic/bytesio.c.h
index 1f736fe..c64ce5c 100644
--- a/Modules/_io/clinic/bytesio.c.h
+++ b/Modules/_io/clinic/bytesio.c.h
@@ -415,10 +415,11 @@ static int
_io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"initial_bytes", NULL};
+ static const char * const _keywords[] = {"initial_bytes", NULL};
+ static _PyArg_Parser _parser = {"|O:BytesIO", _keywords, 0};
PyObject *initvalue = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:BytesIO", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&initvalue)) {
goto exit;
}
@@ -427,4 +428,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=3fdb62f3e3b0544d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6382e8eb578eea64 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h
index 038836a..908fe0f 100644
--- a/Modules/_io/clinic/fileio.c.h
+++ b/Modules/_io/clinic/fileio.c.h
@@ -49,13 +49,14 @@ static int
_io_FileIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ static const char * const _keywords[] = {"file", "mode", "closefd", "opener", NULL};
+ static _PyArg_Parser _parser = {"O|siO:FileIO", _keywords, 0};
PyObject *nameobj;
const char *mode = "r";
int closefd = 1;
PyObject *opener = Py_None;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|siO:FileIO", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&nameobj, &mode, &closefd, &opener)) {
goto exit;
}
@@ -372,4 +373,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=bf4b4bd6b976346d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=51924bc0ee11d58e input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/stringio.c.h b/Modules/_io/clinic/stringio.c.h
index ce9f46e..d2c05d7 100644
--- a/Modules/_io/clinic/stringio.c.h
+++ b/Modules/_io/clinic/stringio.c.h
@@ -221,11 +221,12 @@ static int
_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"initial_value", "newline", NULL};
+ static const char * const _keywords[] = {"initial_value", "newline", NULL};
+ static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0};
PyObject *value = NULL;
PyObject *newline_obj = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:StringIO", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&value, &newline_obj)) {
goto exit;
}
@@ -288,4 +289,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=0513219581cbe952 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5dd5c2a213e75405 input=a9049054013a1b77]*/
diff --git a/Modules/_io/clinic/textio.c.h b/Modules/_io/clinic/textio.c.h
index f115326..6c40819 100644
--- a/Modules/_io/clinic/textio.c.h
+++ b/Modules/_io/clinic/textio.c.h
@@ -24,12 +24,13 @@ static int
_io_IncrementalNewlineDecoder___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"decoder", "translate", "errors", NULL};
+ static const char * const _keywords[] = {"decoder", "translate", "errors", NULL};
+ static _PyArg_Parser _parser = {"Oi|O:IncrementalNewlineDecoder", _keywords, 0};
PyObject *decoder;
int translate;
PyObject *errors = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O:IncrementalNewlineDecoder", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&decoder, &translate, &errors)) {
goto exit;
}
@@ -55,11 +56,12 @@ static PyObject *
_io_IncrementalNewlineDecoder_decode(nldecoder_object *self, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- static char *_keywords[] = {"input", "final", NULL};
+ static const char * const _keywords[] = {"input", "final", NULL};
+ static _PyArg_Parser _parser = {"O|i:decode", _keywords, 0};
PyObject *input;
int final = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:decode", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&input, &final)) {
goto exit;
}
@@ -155,7 +157,8 @@ static int
_io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
- static char *_keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
+ static const char * const _keywords[] = {"buffer", "encoding", "errors", "newline", "line_buffering", "write_through", NULL};
+ static _PyArg_Parser _parser = {"O|zzzii:TextIOWrapper", _keywords, 0};
PyObject *buffer;
const char *encoding = NULL;
const char *errors = NULL;
@@ -163,7 +166,7 @@ _io_TextIOWrapper___init__(PyObject *self, PyObject *args, PyObject *kwargs)
int line_buffering = 0;
int write_through = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|zzzii:TextIOWrapper", _keywords,
+ if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
&buffer, &encoding, &errors, &newline, &line_buffering, &write_through)) {
goto exit;
}
@@ -461,4 +464,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=31a39bbbe07ae4e7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7ec624a9bf6393f5 input=a9049054013a1b77]*/