Skip to content

Commit 259f0e4

Browse files
committed
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.
1 parent 0c8c389 commit 259f0e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1515
-679
lines changed

Modules/_io/clinic/_iomodule.c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,4 @@ _io_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
158158
exit:
159159
return return_value;
160160
}
161-
/*[clinic end generated code: output=c5b8fc8b83102bbf input=a9049054013a1b77]*/
161+
/*[clinic end generated code: output=79fd04d9c9d8f28f input=a9049054013a1b77]*/

Modules/_io/clinic/bufferedio.c.h

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,25 @@ PyDoc_STRVAR(_io__Buffered_peek__doc__,
9191
"\n");
9292

9393
#define _IO__BUFFERED_PEEK_METHODDEF \
94-
{"peek", (PyCFunction)_io__Buffered_peek, METH_VARARGS, _io__Buffered_peek__doc__},
94+
{"peek", (PyCFunction)_io__Buffered_peek, METH_FASTCALL, _io__Buffered_peek__doc__},
9595

9696
static PyObject *
9797
_io__Buffered_peek_impl(buffered *self, Py_ssize_t size);
9898

9999
static PyObject *
100-
_io__Buffered_peek(buffered *self, PyObject *args)
100+
_io__Buffered_peek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
101101
{
102102
PyObject *return_value = NULL;
103103
Py_ssize_t size = 0;
104104

105-
if (!PyArg_ParseTuple(args, "|n:peek",
105+
if (!_PyArg_ParseStack(args, nargs, "|n:peek",
106106
&size)) {
107107
goto exit;
108108
}
109+
110+
if (!_PyArg_NoStackKeywords("peek", kwnames)) {
111+
goto exit;
112+
}
109113
return_value = _io__Buffered_peek_impl(self, size);
110114

111115
exit:
@@ -118,21 +122,25 @@ PyDoc_STRVAR(_io__Buffered_read__doc__,
118122
"\n");
119123

120124
#define _IO__BUFFERED_READ_METHODDEF \
121-
{"read", (PyCFunction)_io__Buffered_read, METH_VARARGS, _io__Buffered_read__doc__},
125+
{"read", (PyCFunction)_io__Buffered_read, METH_FASTCALL, _io__Buffered_read__doc__},
122126

123127
static PyObject *
124128
_io__Buffered_read_impl(buffered *self, Py_ssize_t n);
125129

126130
static PyObject *
127-
_io__Buffered_read(buffered *self, PyObject *args)
131+
_io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
128132
{
129133
PyObject *return_value = NULL;
130134
Py_ssize_t n = -1;
131135

132-
if (!PyArg_ParseTuple(args, "|O&:read",
136+
if (!_PyArg_ParseStack(args, nargs, "|O&:read",
133137
_PyIO_ConvertSsize_t, &n)) {
134138
goto exit;
135139
}
140+
141+
if (!_PyArg_NoStackKeywords("read", kwnames)) {
142+
goto exit;
143+
}
136144
return_value = _io__Buffered_read_impl(self, n);
137145

138146
exit:
@@ -145,21 +153,25 @@ PyDoc_STRVAR(_io__Buffered_read1__doc__,
145153
"\n");
146154

147155
#define _IO__BUFFERED_READ1_METHODDEF \
148-
{"read1", (PyCFunction)_io__Buffered_read1, METH_VARARGS, _io__Buffered_read1__doc__},
156+
{"read1", (PyCFunction)_io__Buffered_read1, METH_FASTCALL, _io__Buffered_read1__doc__},
149157

150158
static PyObject *
151159
_io__Buffered_read1_impl(buffered *self, Py_ssize_t n);
152160

153161
static PyObject *
154-
_io__Buffered_read1(buffered *self, PyObject *args)
162+
_io__Buffered_read1(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
155163
{
156164
PyObject *return_value = NULL;
157165
Py_ssize_t n = -1;
158166

159-
if (!PyArg_ParseTuple(args, "|n:read1",
167+
if (!_PyArg_ParseStack(args, nargs, "|n:read1",
160168
&n)) {
161169
goto exit;
162170
}
171+
172+
if (!_PyArg_NoStackKeywords("read1", kwnames)) {
173+
goto exit;
174+
}
163175
return_value = _io__Buffered_read1_impl(self, n);
164176

165177
exit:
@@ -234,21 +246,25 @@ PyDoc_STRVAR(_io__Buffered_readline__doc__,
234246
"\n");
235247

236248
#define _IO__BUFFERED_READLINE_METHODDEF \
237-
{"readline", (PyCFunction)_io__Buffered_readline, METH_VARARGS, _io__Buffered_readline__doc__},
249+
{"readline", (PyCFunction)_io__Buffered_readline, METH_FASTCALL, _io__Buffered_readline__doc__},
238250

239251
static PyObject *
240252
_io__Buffered_readline_impl(buffered *self, Py_ssize_t size);
241253

242254
static PyObject *
243-
_io__Buffered_readline(buffered *self, PyObject *args)
255+
_io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
244256
{
245257
PyObject *return_value = NULL;
246258
Py_ssize_t size = -1;
247259

248-
if (!PyArg_ParseTuple(args, "|O&:readline",
260+
if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
249261
_PyIO_ConvertSsize_t, &size)) {
250262
goto exit;
251263
}
264+
265+
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
266+
goto exit;
267+
}
252268
return_value = _io__Buffered_readline_impl(self, size);
253269

254270
exit:
@@ -261,22 +277,26 @@ PyDoc_STRVAR(_io__Buffered_seek__doc__,
261277
"\n");
262278

263279
#define _IO__BUFFERED_SEEK_METHODDEF \
264-
{"seek", (PyCFunction)_io__Buffered_seek, METH_VARARGS, _io__Buffered_seek__doc__},
280+
{"seek", (PyCFunction)_io__Buffered_seek, METH_FASTCALL, _io__Buffered_seek__doc__},
265281

266282
static PyObject *
267283
_io__Buffered_seek_impl(buffered *self, PyObject *targetobj, int whence);
268284

269285
static PyObject *
270-
_io__Buffered_seek(buffered *self, PyObject *args)
286+
_io__Buffered_seek(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
271287
{
272288
PyObject *return_value = NULL;
273289
PyObject *targetobj;
274290
int whence = 0;
275291

276-
if (!PyArg_ParseTuple(args, "O|i:seek",
292+
if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
277293
&targetobj, &whence)) {
278294
goto exit;
279295
}
296+
297+
if (!_PyArg_NoStackKeywords("seek", kwnames)) {
298+
goto exit;
299+
}
280300
return_value = _io__Buffered_seek_impl(self, targetobj, whence);
281301

282302
exit:
@@ -476,4 +496,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs)
476496
exit:
477497
return return_value;
478498
}
479-
/*[clinic end generated code: output=490c97bfcfd92c51 input=a9049054013a1b77]*/
499+
/*[clinic end generated code: output=e6e584216a10d67e input=a9049054013a1b77]*/

Modules/_io/clinic/bytesio.c.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,26 @@ PyDoc_STRVAR(_io_BytesIO_seek__doc__,
358358
"Returns the new absolute position.");
359359

360360
#define _IO_BYTESIO_SEEK_METHODDEF \
361-
{"seek", (PyCFunction)_io_BytesIO_seek, METH_VARARGS, _io_BytesIO_seek__doc__},
361+
{"seek", (PyCFunction)_io_BytesIO_seek, METH_FASTCALL, _io_BytesIO_seek__doc__},
362362

363363
static PyObject *
364364
_io_BytesIO_seek_impl(bytesio *self, Py_ssize_t pos, int whence);
365365

366366
static PyObject *
367-
_io_BytesIO_seek(bytesio *self, PyObject *args)
367+
_io_BytesIO_seek(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
368368
{
369369
PyObject *return_value = NULL;
370370
Py_ssize_t pos;
371371
int whence = 0;
372372

373-
if (!PyArg_ParseTuple(args, "n|i:seek",
373+
if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
374374
&pos, &whence)) {
375375
goto exit;
376376
}
377+
378+
if (!_PyArg_NoStackKeywords("seek", kwnames)) {
379+
goto exit;
380+
}
377381
return_value = _io_BytesIO_seek_impl(self, pos, whence);
378382

379383
exit:
@@ -448,4 +452,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
448452
exit:
449453
return return_value;
450454
}
451-
/*[clinic end generated code: output=8f469431da1b3857 input=a9049054013a1b77]*/
455+
/*[clinic end generated code: output=056f24eece495a8f input=a9049054013a1b77]*/

Modules/_io/clinic/fileio.c.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,25 @@ PyDoc_STRVAR(_io_FileIO_read__doc__,
202202
"Return an empty bytes object at EOF.");
203203

204204
#define _IO_FILEIO_READ_METHODDEF \
205-
{"read", (PyCFunction)_io_FileIO_read, METH_VARARGS, _io_FileIO_read__doc__},
205+
{"read", (PyCFunction)_io_FileIO_read, METH_FASTCALL, _io_FileIO_read__doc__},
206206

207207
static PyObject *
208208
_io_FileIO_read_impl(fileio *self, Py_ssize_t size);
209209

210210
static PyObject *
211-
_io_FileIO_read(fileio *self, PyObject *args)
211+
_io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
212212
{
213213
PyObject *return_value = NULL;
214214
Py_ssize_t size = -1;
215215

216-
if (!PyArg_ParseTuple(args, "|O&:read",
216+
if (!_PyArg_ParseStack(args, nargs, "|O&:read",
217217
_PyIO_ConvertSsize_t, &size)) {
218218
goto exit;
219219
}
220+
221+
if (!_PyArg_NoStackKeywords("read", kwnames)) {
222+
goto exit;
223+
}
220224
return_value = _io_FileIO_read_impl(self, size);
221225

222226
exit:
@@ -274,22 +278,26 @@ PyDoc_STRVAR(_io_FileIO_seek__doc__,
274278
"Note that not all file objects are seekable.");
275279

276280
#define _IO_FILEIO_SEEK_METHODDEF \
277-
{"seek", (PyCFunction)_io_FileIO_seek, METH_VARARGS, _io_FileIO_seek__doc__},
281+
{"seek", (PyCFunction)_io_FileIO_seek, METH_FASTCALL, _io_FileIO_seek__doc__},
278282

279283
static PyObject *
280284
_io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence);
281285

282286
static PyObject *
283-
_io_FileIO_seek(fileio *self, PyObject *args)
287+
_io_FileIO_seek(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
284288
{
285289
PyObject *return_value = NULL;
286290
PyObject *pos;
287291
int whence = 0;
288292

289-
if (!PyArg_ParseTuple(args, "O|i:seek",
293+
if (!_PyArg_ParseStack(args, nargs, "O|i:seek",
290294
&pos, &whence)) {
291295
goto exit;
292296
}
297+
298+
if (!_PyArg_NoStackKeywords("seek", kwnames)) {
299+
goto exit;
300+
}
293301
return_value = _io_FileIO_seek_impl(self, pos, whence);
294302

295303
exit:
@@ -373,4 +381,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
373381
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
374382
#define _IO_FILEIO_TRUNCATE_METHODDEF
375383
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
376-
/*[clinic end generated code: output=51924bc0ee11d58e input=a9049054013a1b77]*/
384+
/*[clinic end generated code: output=5c2a0b493c0af58b input=a9049054013a1b77]*/

Modules/_io/clinic/iobase.c.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,25 @@ PyDoc_STRVAR(_io__IOBase_readline__doc__,
174174
"terminator(s) recognized.");
175175

176176
#define _IO__IOBASE_READLINE_METHODDEF \
177-
{"readline", (PyCFunction)_io__IOBase_readline, METH_VARARGS, _io__IOBase_readline__doc__},
177+
{"readline", (PyCFunction)_io__IOBase_readline, METH_FASTCALL, _io__IOBase_readline__doc__},
178178

179179
static PyObject *
180180
_io__IOBase_readline_impl(PyObject *self, Py_ssize_t limit);
181181

182182
static PyObject *
183-
_io__IOBase_readline(PyObject *self, PyObject *args)
183+
_io__IOBase_readline(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
184184
{
185185
PyObject *return_value = NULL;
186186
Py_ssize_t limit = -1;
187187

188-
if (!PyArg_ParseTuple(args, "|O&:readline",
188+
if (!_PyArg_ParseStack(args, nargs, "|O&:readline",
189189
_PyIO_ConvertSsize_t, &limit)) {
190190
goto exit;
191191
}
192+
193+
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
194+
goto exit;
195+
}
192196
return_value = _io__IOBase_readline_impl(self, limit);
193197

194198
exit:
@@ -206,21 +210,25 @@ PyDoc_STRVAR(_io__IOBase_readlines__doc__,
206210
"lines so far exceeds hint.");
207211

208212
#define _IO__IOBASE_READLINES_METHODDEF \
209-
{"readlines", (PyCFunction)_io__IOBase_readlines, METH_VARARGS, _io__IOBase_readlines__doc__},
213+
{"readlines", (PyCFunction)_io__IOBase_readlines, METH_FASTCALL, _io__IOBase_readlines__doc__},
210214

211215
static PyObject *
212216
_io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint);
213217

214218
static PyObject *
215-
_io__IOBase_readlines(PyObject *self, PyObject *args)
219+
_io__IOBase_readlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
216220
{
217221
PyObject *return_value = NULL;
218222
Py_ssize_t hint = -1;
219223

220-
if (!PyArg_ParseTuple(args, "|O&:readlines",
224+
if (!_PyArg_ParseStack(args, nargs, "|O&:readlines",
221225
_PyIO_ConvertSsize_t, &hint)) {
222226
goto exit;
223227
}
228+
229+
if (!_PyArg_NoStackKeywords("readlines", kwnames)) {
230+
goto exit;
231+
}
224232
return_value = _io__IOBase_readlines_impl(self, hint);
225233

226234
exit:
@@ -241,21 +249,25 @@ PyDoc_STRVAR(_io__RawIOBase_read__doc__,
241249
"\n");
242250

243251
#define _IO__RAWIOBASE_READ_METHODDEF \
244-
{"read", (PyCFunction)_io__RawIOBase_read, METH_VARARGS, _io__RawIOBase_read__doc__},
252+
{"read", (PyCFunction)_io__RawIOBase_read, METH_FASTCALL, _io__RawIOBase_read__doc__},
245253

246254
static PyObject *
247255
_io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n);
248256

249257
static PyObject *
250-
_io__RawIOBase_read(PyObject *self, PyObject *args)
258+
_io__RawIOBase_read(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
251259
{
252260
PyObject *return_value = NULL;
253261
Py_ssize_t n = -1;
254262

255-
if (!PyArg_ParseTuple(args, "|n:read",
263+
if (!_PyArg_ParseStack(args, nargs, "|n:read",
256264
&n)) {
257265
goto exit;
258266
}
267+
268+
if (!_PyArg_NoStackKeywords("read", kwnames)) {
269+
goto exit;
270+
}
259271
return_value = _io__RawIOBase_read_impl(self, n);
260272

261273
exit:
@@ -279,4 +291,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
279291
{
280292
return _io__RawIOBase_readall_impl(self);
281293
}
282-
/*[clinic end generated code: output=0f53fed928d8e02f input=a9049054013a1b77]*/
294+
/*[clinic end generated code: output=1bcece367fc7b0cd input=a9049054013a1b77]*/

Modules/_io/clinic/stringio.c.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,26 @@ PyDoc_STRVAR(_io_StringIO_seek__doc__,
147147
"Returns the new absolute position.");
148148

149149
#define _IO_STRINGIO_SEEK_METHODDEF \
150-
{"seek", (PyCFunction)_io_StringIO_seek, METH_VARARGS, _io_StringIO_seek__doc__},
150+
{"seek", (PyCFunction)_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__},
151151

152152
static PyObject *
153153
_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
154154

155155
static PyObject *
156-
_io_StringIO_seek(stringio *self, PyObject *args)
156+
_io_StringIO_seek(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
157157
{
158158
PyObject *return_value = NULL;
159159
Py_ssize_t pos;
160160
int whence = 0;
161161

162-
if (!PyArg_ParseTuple(args, "n|i:seek",
162+
if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
163163
&pos, &whence)) {
164164
goto exit;
165165
}
166+
167+
if (!_PyArg_NoStackKeywords("seek", kwnames)) {
168+
goto exit;
169+
}
166170
return_value = _io_StringIO_seek_impl(self, pos, whence);
167171

168172
exit:
@@ -289,4 +293,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
289293
{
290294
return _io_StringIO_seekable_impl(self);
291295
}
292-
/*[clinic end generated code: output=5dd5c2a213e75405 input=a9049054013a1b77]*/
296+
/*[clinic end generated code: output=69bf262268745061 input=a9049054013a1b77]*/

0 commit comments

Comments
 (0)