mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)
This commit is contained in:
parent
b4bee03087
commit
b1263d5a60
7 changed files with 105 additions and 33 deletions
|
|
@ -851,15 +851,22 @@ static PySequenceMethods mappingproxy_as_sequence = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
mappingproxy_get(mappingproxyobject *pp, PyObject *args)
|
||||
mappingproxy_get(mappingproxyobject *pp, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *key, *def = Py_None;
|
||||
_Py_IDENTIFIER(get);
|
||||
/* newargs: mapping, key, default=None */
|
||||
PyObject *newargs[3];
|
||||
newargs[0] = pp->mapping;
|
||||
newargs[2] = Py_None;
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
|
||||
if (!_PyArg_UnpackStack(args, nargs, "get", 1, 2,
|
||||
&newargs[1], &newargs[2]))
|
||||
{
|
||||
return NULL;
|
||||
return _PyObject_CallMethodIdObjArgs(pp->mapping, &PyId_get,
|
||||
key, def, NULL);
|
||||
}
|
||||
_Py_IDENTIFIER(get);
|
||||
return _PyObject_VectorcallMethodId(&PyId_get, newargs,
|
||||
3 | PY_VECTORCALL_ARGUMENTS_OFFSET,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
@ -894,7 +901,7 @@ mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored))
|
|||
to the underlying mapping */
|
||||
|
||||
static PyMethodDef mappingproxy_methods[] = {
|
||||
{"get", (PyCFunction)mappingproxy_get, METH_VARARGS,
|
||||
{"get", (PyCFunction)mappingproxy_get, METH_FASTCALL,
|
||||
PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d."
|
||||
" d defaults to None.")},
|
||||
{"keys", (PyCFunction)mappingproxy_keys, METH_NOARGS,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue