summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorJeroen Demeyer <J.Demeyer@UGent.be>2019-06-28 09:49:00 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-06-28 09:49:00 (GMT)
commitb1263d5a60d3f7ab02dd28409fff59b3815a3f67 (patch)
treed2b48c8ffcf6b8d4c042495e0b8888b7deda086e /Objects/descrobject.c
parentb4bee03087a3c70cb040e2ce569c828860ed8e87 (diff)
downloadcpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.zip
cpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.tar.gz
cpython-b1263d5a60d3f7ab02dd28409fff59b3815a3f67.tar.bz2
bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228)
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 806c0af..a0eb505 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -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,