mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Backporting METH_FASTCALL from Python 3.7 (#317)
* dict copy speedup refer to bpo-31179 or python/cpython@boa7a037b8fde * __build_class__() uses METH_FASTCALL refer python/cpython@69de71b255 refer python/cpython@773dc6dd06 a single test related to __prepare__ fails. * type_prepare uses METH_FASTCALL refer python/cpython@d526cfe546 refer python/cpython@80ab22fa2c the prepare-related test still fails. It's just related to the error message format though. * separate into ParseStack and ParseStackAndKeywords refer python/cpython@6518a93cb1 refer python/cpython@3e1fad6913 refer python/cpython@c0083fc47d * Add _PyArg_NoStackKeywords refer python/cpython@29d39cc8f5 * _PyStack_UnpackDict now returns int refer python/cpython@998c20962c * METH_FASTCALL changes to .inc files done via python's Argument Clinic tool, refer python/cpython@259f0e4437 * Added _PyArg_UnpackStack refer python/cpython@fe54dda08 * Argument Clinic FASTCALL again refer python/cpython@0c4a828ca * Argument Clinic for ordered dictionary object refer python/cpython@b05cbac052 * speed up getargs refer python/cpython@1741441649 * FASTCALL for sorted, next, and getattr refer python/cpython@5a60ecaa7a refer python/cpython@fda6d0acf0 refer python/cpython@84b388bb80 * Optimize methoddescr_call refer python/cpython@2a1b676d1f refer python/cpython@c52572319c refer python/cpython@35ecebe165 refer python/cpython@8128d5a491 * cleanup _PyMethodDef_RawFastCallDict refer python/cpython@0a2e46835d refer python/cpython@98ccba8344 refer python/cpython@c89ef828cf refer python/cpython@250e4b0063 * print now uses METH_FASTCALL refer python/cpython@c3858bd7c6 refer python/cpython@bd584f169f refer python/cpython@06d34393c2 * _struct module now uses Argument Clinic refer python/cpython@3f2d10132d * make deque methods faster refer python/cpython@dd407d5006 * recursive calls in PyObject_Call refer python/cpython@7399a05965 only partially ported, because RawFastCallKeywords hasn't been ported * add macros refer python/cpython@68a001dd59 * all tests pass in MODE=dbg * convert some internal functions to FASTCALL __import__ might need to be changed later, if it is possible to backport the METH_FASTCALL | METH_KEYWORDS flag distinction later. * speed up unpickling refer python/cpython@bee09aecc2 * added _PyMethodDef_RawFastCallKeywords refer python/cpython@7399a05965 * PyCFunction_Call performance refer python/cpython@12c5838dae * avoid PyMethodObject in slots main change in python/cpython@516b98161a test_exceptions changed in python/cpython@331bbe6aaa type_settattro changed in python/cpython@193f7e094f _PyObject_CallFunctionVa changed in python/cpython@fe4ff83049 * fix refcount error found in MODE=dbg all tests now pass in MODE=dbg
This commit is contained in:
parent
6f658f058b
commit
7fe9e70117
71 changed files with 4154 additions and 2450 deletions
|
@ -1,11 +1,4 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
/* clang-format off */
|
||||
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
@ -74,7 +67,7 @@ bytearray_translate(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs,
|
|||
PyObject *table;
|
||||
PyObject *deletechars = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&table, &deletechars)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -96,22 +89,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:
|
||||
|
@ -141,24 +138,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:
|
||||
|
@ -204,7 +205,7 @@ bytearray_split(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyOb
|
|||
PyObject *sep = Py_None;
|
||||
Py_ssize_t maxsplit = -1;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&sep, &maxsplit)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -279,7 +280,7 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO
|
|||
PyObject *sep = Py_None;
|
||||
Py_ssize_t maxsplit = -1;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&sep, &maxsplit)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -319,22 +320,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:
|
||||
|
@ -396,21 +401,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:
|
||||
|
@ -456,22 +465,26 @@ PyDoc_STRVAR(bytearray_strip__doc__,
|
|||
"If the argument is omitted or None, strip leading and trailing ASCII whitespace.");
|
||||
|
||||
#define BYTEARRAY_STRIP_METHODDEF \
|
||||
{"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__},
|
||||
{"strip", (PyCFunction)bytearray_strip, METH_FASTCALL, bytearray_strip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytearray_strip(PyByteArrayObject *self, PyObject *args)
|
||||
bytearray_strip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "strip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "strip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("strip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytearray_strip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -487,22 +500,26 @@ PyDoc_STRVAR(bytearray_lstrip__doc__,
|
|||
"If the argument is omitted or None, strip leading ASCII whitespace.");
|
||||
|
||||
#define BYTEARRAY_LSTRIP_METHODDEF \
|
||||
{"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__},
|
||||
{"lstrip", (PyCFunction)bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytearray_lstrip(PyByteArrayObject *self, PyObject *args)
|
||||
bytearray_lstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "lstrip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "lstrip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("lstrip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytearray_lstrip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -518,22 +535,26 @@ PyDoc_STRVAR(bytearray_rstrip__doc__,
|
|||
"If the argument is omitted or None, strip trailing ASCII whitespace.");
|
||||
|
||||
#define BYTEARRAY_RSTRIP_METHODDEF \
|
||||
{"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__},
|
||||
{"rstrip", (PyCFunction)bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytearray_rstrip(PyByteArrayObject *self, PyObject *args)
|
||||
bytearray_rstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "rstrip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "rstrip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("rstrip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytearray_rstrip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -571,7 +592,7 @@ bytearray_decode(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO
|
|||
const char *encoding = NULL;
|
||||
const char *errors = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&encoding, &errors)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -617,7 +638,7 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs,
|
|||
static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0};
|
||||
int keepends = 0;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&keepends)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -682,21 +703,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:
|
||||
|
@ -720,4 +745,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return bytearray_sizeof_impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=8f022100f059226c input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=c1b1b83b0e19df74 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
/* clang-format off */
|
||||
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
@ -39,7 +32,7 @@ bytes_split(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kw
|
|||
PyObject *sep = Py_None;
|
||||
Py_ssize_t maxsplit = -1;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&sep, &maxsplit)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -158,7 +151,7 @@ bytes_rsplit(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k
|
|||
PyObject *sep = Py_None;
|
||||
Py_ssize_t maxsplit = -1;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&sep, &maxsplit)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -192,22 +185,26 @@ PyDoc_STRVAR(bytes_strip__doc__,
|
|||
"If the argument is omitted or None, strip leading and trailing ASCII whitespace.");
|
||||
|
||||
#define BYTES_STRIP_METHODDEF \
|
||||
{"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__},
|
||||
{"strip", (PyCFunction)bytes_strip, METH_FASTCALL, bytes_strip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_strip_impl(PyBytesObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytes_strip(PyBytesObject *self, PyObject *args)
|
||||
bytes_strip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "strip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "strip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("strip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytes_strip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -223,22 +220,26 @@ PyDoc_STRVAR(bytes_lstrip__doc__,
|
|||
"If the argument is omitted or None, strip leading ASCII whitespace.");
|
||||
|
||||
#define BYTES_LSTRIP_METHODDEF \
|
||||
{"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__},
|
||||
{"lstrip", (PyCFunction)bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytes_lstrip(PyBytesObject *self, PyObject *args)
|
||||
bytes_lstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "lstrip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "lstrip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("lstrip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytes_lstrip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -254,22 +255,26 @@ PyDoc_STRVAR(bytes_rstrip__doc__,
|
|||
"If the argument is omitted or None, strip trailing ASCII whitespace.");
|
||||
|
||||
#define BYTES_RSTRIP_METHODDEF \
|
||||
{"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__},
|
||||
{"rstrip", (PyCFunction)bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__},
|
||||
|
||||
static PyObject *
|
||||
bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes);
|
||||
|
||||
static PyObject *
|
||||
bytes_rstrip(PyBytesObject *self, PyObject *args)
|
||||
bytes_rstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *bytes = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "rstrip",
|
||||
if (!_PyArg_UnpackStack(args, nargs, "rstrip",
|
||||
0, 1,
|
||||
&bytes)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("rstrip", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = bytes_rstrip_impl(self, bytes);
|
||||
|
||||
exit:
|
||||
|
@ -304,7 +309,7 @@ bytes_translate(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject
|
|||
PyObject *table;
|
||||
PyObject *deletechars = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&table, &deletechars)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -326,22 +331,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:
|
||||
|
@ -371,24 +380,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:
|
||||
|
@ -435,7 +448,7 @@ bytes_decode(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k
|
|||
const char *encoding = NULL;
|
||||
const char *errors = NULL;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&encoding, &errors)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -468,7 +481,7 @@ bytes_splitlines(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObjec
|
|||
static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0};
|
||||
int keepends = 0;
|
||||
|
||||
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&keepends)) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -507,4 +520,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=4ac7e35150d47467 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=debf785947e0eec2 input=a9049054013a1b77]*/
|
||||
|
|
69
third_party/python/Objects/clinic/dictobject.inc
vendored
69
third_party/python/Objects/clinic/dictobject.inc
vendored
|
@ -1,49 +1,48 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
/* clang-format off */
|
||||
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
PyDoc_STRVAR(
|
||||
dict_fromkeys__doc__,
|
||||
"fromkeys($type, iterable, value=None, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Returns a new dict with keys from iterable and values equal to value.");
|
||||
PyDoc_STRVAR(dict_fromkeys__doc__,
|
||||
"fromkeys($type, iterable, value=None, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Returns a new dict with keys from iterable and values equal to value.");
|
||||
|
||||
#define DICT_FROMKEYS_METHODDEF \
|
||||
{"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS | METH_CLASS, \
|
||||
dict_fromkeys__doc__},
|
||||
#define DICT_FROMKEYS_METHODDEF \
|
||||
{"fromkeys", (PyCFunction)dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__},
|
||||
|
||||
static PyObject *dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable,
|
||||
PyObject *value);
|
||||
static PyObject *
|
||||
dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value);
|
||||
|
||||
static PyObject *dict_fromkeys(PyTypeObject *type, PyObject *args) {
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *iterable;
|
||||
PyObject *value = Py_None;
|
||||
static PyObject *
|
||||
dict_fromkeys(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *iterable;
|
||||
PyObject *value = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "fromkeys", 1, 2, &iterable, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = dict_fromkeys_impl(type, iterable, value);
|
||||
if (!_PyArg_UnpackStack(args, nargs, "fromkeys",
|
||||
1, 2,
|
||||
&iterable, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!_PyArg_NoStackKeywords("fromkeys", kwnames)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = dict_fromkeys_impl(type, iterable, value);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(dict___contains____doc__, "__contains__($self, key, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"True if D has a key k, else False.");
|
||||
PyDoc_STRVAR(dict___contains____doc__,
|
||||
"__contains__($self, key, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"True if D has a key k, else False.");
|
||||
|
||||
#define DICT___CONTAINS___METHODDEF \
|
||||
{"__contains__", (PyCFunction)dict___contains__, METH_O | METH_COEXIST, \
|
||||
dict___contains____doc__},
|
||||
/*[clinic end generated code: output=926326109e3d9839 input=a9049054013a1b77]*/
|
||||
#define DICT___CONTAINS___METHODDEF \
|
||||
{"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__},
|
||||
/*[clinic end generated code: output=69f3d767ed44e8ec input=a9049054013a1b77]*/
|
||||
|
|
136
third_party/python/Objects/clinic/odictobject.inc
vendored
Normal file
136
third_party/python/Objects/clinic/odictobject.inc
vendored
Normal file
|
@ -0,0 +1,136 @@
|
|||
/* clang-format off */
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
PyDoc_STRVAR(OrderedDict_fromkeys__doc__,
|
||||
"fromkeys($type, /, iterable, value=None)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"New ordered dictionary with keys from S.\n"
|
||||
"\n"
|
||||
"If not specified, the value defaults to None.");
|
||||
|
||||
#define ORDEREDDICT_FROMKEYS_METHODDEF \
|
||||
{"fromkeys", (PyCFunction)OrderedDict_fromkeys, METH_FASTCALL|METH_CLASS, OrderedDict_fromkeys__doc__},
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value);
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_fromkeys(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"iterable", "value", NULL};
|
||||
static _PyArg_Parser _parser = {"O|O:fromkeys", _keywords, 0};
|
||||
PyObject *seq;
|
||||
PyObject *value = Py_None;
|
||||
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&seq, &value)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = OrderedDict_fromkeys_impl(type, seq, value);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(OrderedDict_setdefault__doc__,
|
||||
"setdefault($self, /, key, default=None)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"od.get(k,d), also set od[k]=d if k not in od.");
|
||||
|
||||
#define ORDEREDDICT_SETDEFAULT_METHODDEF \
|
||||
{"setdefault", (PyCFunction)OrderedDict_setdefault, METH_FASTCALL, OrderedDict_setdefault__doc__},
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key,
|
||||
PyObject *failobj);
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_setdefault(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"key", "default", NULL};
|
||||
static _PyArg_Parser _parser = {"O|O:setdefault", _keywords, 0};
|
||||
PyObject *key;
|
||||
PyObject *failobj = Py_None;
|
||||
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&key, &failobj)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = OrderedDict_setdefault_impl(self, key, failobj);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(OrderedDict_popitem__doc__,
|
||||
"popitem($self, /, last=True)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Return (k, v) and remove a (key, value) pair.\n"
|
||||
"\n"
|
||||
"Pairs are returned in LIFO order if last is true or FIFO order if false.");
|
||||
|
||||
#define ORDEREDDICT_POPITEM_METHODDEF \
|
||||
{"popitem", (PyCFunction)OrderedDict_popitem, METH_FASTCALL, OrderedDict_popitem__doc__},
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_popitem_impl(PyODictObject *self, int last);
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_popitem(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"last", NULL};
|
||||
static _PyArg_Parser _parser = {"|p:popitem", _keywords, 0};
|
||||
int last = 1;
|
||||
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&last)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = OrderedDict_popitem_impl(self, last);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(OrderedDict_move_to_end__doc__,
|
||||
"move_to_end($self, /, key, last=True)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"\"Move an existing element to the end (or beginning if last==False).\n"
|
||||
"\n"
|
||||
" Raises KeyError if the element does not exist.\n"
|
||||
" When last=True, acts like a fast version of self[key]=self.pop(key).");
|
||||
|
||||
#define ORDEREDDICT_MOVE_TO_END_METHODDEF \
|
||||
{"move_to_end", (PyCFunction)OrderedDict_move_to_end, METH_FASTCALL, OrderedDict_move_to_end__doc__},
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_move_to_end_impl(PyODictObject *self, PyObject *key, int last);
|
||||
|
||||
static PyObject *
|
||||
OrderedDict_move_to_end(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
static const char * const _keywords[] = {"key", "last", NULL};
|
||||
static _PyArg_Parser _parser = {"O|p:move_to_end", _keywords, 0};
|
||||
PyObject *key;
|
||||
int last = 1;
|
||||
|
||||
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
|
||||
&key, &last)) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = OrderedDict_move_to_end_impl(self, key, last);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=f2641e1277045b59 input=a9049054013a1b77]*/
|
|
@ -1,11 +1,4 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
/* clang-format off */
|
||||
|
||||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
@ -25,26 +18,30 @@ 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:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=4a86dd108d92d104 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=af4804dbf21463b5 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue