2015-04-03 20:53:51 +00:00
|
|
|
/*[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.");
|
|
|
|
|
|
|
|
#define DICT_FROMKEYS_METHODDEF \
|
2017-01-17 01:21:47 +00:00
|
|
|
{"fromkeys", (PyCFunction)dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__},
|
2015-04-03 20:53:51 +00:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-01-17 01:21:47 +00:00
|
|
|
dict_fromkeys(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
2015-04-03 20:53:51 +00:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *iterable;
|
|
|
|
PyObject *value = Py_None;
|
|
|
|
|
2017-01-17 01:21:47 +00:00
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "fromkeys",
|
2015-04-03 20:53:51 +00:00
|
|
|
1, 2,
|
2016-06-09 13:16:06 +00:00
|
|
|
&iterable, &value)) {
|
2015-04-03 20:53:51 +00:00
|
|
|
goto exit;
|
2016-06-09 13:16:06 +00:00
|
|
|
}
|
2017-01-17 01:21:47 +00:00
|
|
|
|
|
|
|
if (!_PyArg_NoStackKeywords("fromkeys", kwnames)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-04-03 20:53:51 +00:00
|
|
|
return_value = dict_fromkeys_impl(type, iterable, value);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
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__},
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
PyDoc_STRVAR(dict_get__doc__,
|
|
|
|
"get($self, key, default=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"D.get(key[, default]) -> D[key] if key in D, else default.");
|
|
|
|
|
|
|
|
#define DICT_GET_METHODDEF \
|
|
|
|
{"get", (PyCFunction)dict_get, METH_FASTCALL, dict_get__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
2017-01-19 17:00:30 +00:00
|
|
|
dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict_get(PyDictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *key;
|
2017-01-19 17:00:30 +00:00
|
|
|
PyObject *default_value = Py_None;
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "get",
|
|
|
|
1, 2,
|
2017-01-19 17:00:30 +00:00
|
|
|
&key, &default_value)) {
|
2017-01-19 11:37:13 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_PyArg_NoStackKeywords("get", kwnames)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-01-19 17:00:30 +00:00
|
|
|
return_value = dict_get_impl(self, key, default_value);
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(dict_setdefault__doc__,
|
|
|
|
"setdefault($self, key, default=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"D.get(key,default), also set D[key]=default if key not in D.");
|
|
|
|
|
|
|
|
#define DICT_SETDEFAULT_METHODDEF \
|
|
|
|
{"setdefault", (PyCFunction)dict_setdefault, METH_FASTCALL, dict_setdefault__doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
2017-01-19 17:00:30 +00:00
|
|
|
dict_setdefault_impl(PyDictObject *self, PyObject *key,
|
|
|
|
PyObject *default_value);
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict_setdefault(PyDictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *key;
|
2017-01-19 17:00:30 +00:00
|
|
|
PyObject *default_value = Py_None;
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "setdefault",
|
|
|
|
1, 2,
|
2017-01-19 17:00:30 +00:00
|
|
|
&key, &default_value)) {
|
2017-01-19 11:37:13 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_PyArg_NoStackKeywords("setdefault", kwnames)) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2017-01-19 17:00:30 +00:00
|
|
|
return_value = dict_setdefault_impl(self, key, default_value);
|
2017-01-19 11:37:13 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2017-01-19 17:00:30 +00:00
|
|
|
/*[clinic end generated code: output=6e9d917602373072 input=a9049054013a1b77]*/
|