2015-04-03 17:53:51 -03:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
PyDoc_STRVAR(dict_fromkeys__doc__,
|
|
|
|
"fromkeys($type, iterable, value=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
2017-01-24 18:30:04 -04:00
|
|
|
"Create a new dictionary with keys from iterable and values set to value.");
|
2015-04-03 17:53:51 -03:00
|
|
|
|
|
|
|
#define DICT_FROMKEYS_METHODDEF \
|
2018-11-27 05:27:36 -04:00
|
|
|
{"fromkeys", (PyCFunction)(void(*)(void))dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__},
|
2015-04-03 17:53:51 -03:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value);
|
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
|
2015-04-03 17:53:51 -03:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *iterable;
|
|
|
|
PyObject *value = Py_None;
|
|
|
|
|
2017-06-10 01:51:48 -03:00
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "fromkeys",
|
|
|
|
1, 2,
|
|
|
|
&iterable, &value)) {
|
2017-01-16 21:21:47 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2015-04-03 17:53:51 -03:00
|
|
|
return_value = dict_fromkeys_impl(type, iterable, value);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(dict___contains____doc__,
|
|
|
|
"__contains__($self, key, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
2017-02-04 02:05:07 -04:00
|
|
|
"True if the dictionary has the specified key, else False.");
|
2015-04-03 17:53:51 -03:00
|
|
|
|
|
|
|
#define DICT___CONTAINS___METHODDEF \
|
|
|
|
{"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__},
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
PyDoc_STRVAR(dict_get__doc__,
|
|
|
|
"get($self, key, default=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
2017-01-24 18:30:04 -04:00
|
|
|
"Return the value for key if key is in the dictionary, else default.");
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
#define DICT_GET_METHODDEF \
|
2018-11-27 05:27:36 -04:00
|
|
|
{"get", (PyCFunction)(void(*)(void))dict_get, METH_FASTCALL, dict_get__doc__},
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2017-01-19 13:00:30 -04:00
|
|
|
dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
dict_get(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2017-01-19 07:37:13 -04:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *key;
|
2017-01-19 13:00:30 -04:00
|
|
|
PyObject *default_value = Py_None;
|
2017-01-19 07:37:13 -04:00
|
|
|
|
2017-06-10 01:51:48 -03:00
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "get",
|
|
|
|
1, 2,
|
|
|
|
&key, &default_value)) {
|
2017-01-19 07:37:13 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2017-01-19 13:00:30 -04:00
|
|
|
return_value = dict_get_impl(self, key, default_value);
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyDoc_STRVAR(dict_setdefault__doc__,
|
|
|
|
"setdefault($self, key, default=None, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
2017-01-24 18:30:04 -04:00
|
|
|
"Insert key with a value of default if key is not in the dictionary.\n"
|
|
|
|
"\n"
|
|
|
|
"Return the value for key if key is in the dictionary, else default.");
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
#define DICT_SETDEFAULT_METHODDEF \
|
2018-11-27 05:27:36 -04:00
|
|
|
{"setdefault", (PyCFunction)(void(*)(void))dict_setdefault, METH_FASTCALL, dict_setdefault__doc__},
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2017-01-19 13:00:30 -04:00
|
|
|
dict_setdefault_impl(PyDictObject *self, PyObject *key,
|
|
|
|
PyObject *default_value);
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
static PyObject *
|
2017-12-15 07:11:11 -04:00
|
|
|
dict_setdefault(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2017-01-19 07:37:13 -04:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *key;
|
2017-01-19 13:00:30 -04:00
|
|
|
PyObject *default_value = Py_None;
|
2017-01-19 07:37:13 -04:00
|
|
|
|
2017-06-10 01:51:48 -03:00
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "setdefault",
|
|
|
|
1, 2,
|
|
|
|
&key, &default_value)) {
|
2017-01-19 07:37:13 -04:00
|
|
|
goto exit;
|
|
|
|
}
|
2017-01-19 13:00:30 -04:00
|
|
|
return_value = dict_setdefault_impl(self, key, default_value);
|
2017-01-19 07:37:13 -04:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
2018-11-05 20:38:54 -04:00
|
|
|
|
|
|
|
PyDoc_STRVAR(dict___reversed____doc__,
|
|
|
|
"__reversed__($self, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Return a reverse iterator over the dict keys.");
|
|
|
|
|
|
|
|
#define DICT___REVERSED___METHODDEF \
|
|
|
|
{"__reversed__", (PyCFunction)dict___reversed__, METH_NOARGS, dict___reversed____doc__},
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict___reversed___impl(PyDictObject *self);
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
|
|
|
|
{
|
|
|
|
return dict___reversed___impl(self);
|
|
|
|
}
|
2018-11-27 05:27:36 -04:00
|
|
|
/*[clinic end generated code: output=193e08cb8099fe22 input=a9049054013a1b77]*/
|