1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
/*[clinic input]
preserve
[clinic start generated code]*/
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
PyDoc_STRVAR(dict_fromkeys__doc__,
"fromkeys($type, iterable, value=None, /)\n"
"--\n"
"\n"
"Create a new dictionary with keys from iterable and values set to value.");
#define DICT_FROMKEYS_METHODDEF \
{"fromkeys", _PyCFunction_CAST(dict_fromkeys), METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__},
static PyObject *
dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value);
static PyObject *
dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *iterable;
PyObject *value = Py_None;
if (!_PyArg_CheckPositional("fromkeys", nargs, 1, 2)) {
goto exit;
}
iterable = args[0];
if (nargs < 2) {
goto skip_optional;
}
value = args[1];
skip_optional:
return_value = dict_fromkeys_impl(type, iterable, value);
exit:
return return_value;
}
PyDoc_STRVAR(dict_copy__doc__,
"copy($self, /)\n"
"--\n"
"\n"
"Return a shallow copy of the dict.");
#define DICT_COPY_METHODDEF \
{"copy", (PyCFunction)dict_copy, METH_NOARGS, dict_copy__doc__},
static PyObject *
dict_copy_impl(PyDictObject *self);
static PyObject *
dict_copy(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict_copy_impl(self);
}
PyDoc_STRVAR(dict___contains____doc__,
"__contains__($self, key, /)\n"
"--\n"
"\n"
"True if the dictionary has the specified key, else False.");
#define DICT___CONTAINS___METHODDEF \
{"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__},
PyDoc_STRVAR(dict_get__doc__,
"get($self, key, default=None, /)\n"
"--\n"
"\n"
"Return the value for key if key is in the dictionary, else default.");
#define DICT_GET_METHODDEF \
{"get", _PyCFunction_CAST(dict_get), METH_FASTCALL, dict_get__doc__},
static PyObject *
dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
static PyObject *
dict_get(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *key;
PyObject *default_value = Py_None;
if (!_PyArg_CheckPositional("get", nargs, 1, 2)) {
goto exit;
}
key = args[0];
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = dict_get_impl(self, key, default_value);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
}
PyDoc_STRVAR(dict_setdefault__doc__,
"setdefault($self, key, default=None, /)\n"
"--\n"
"\n"
"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.");
#define DICT_SETDEFAULT_METHODDEF \
{"setdefault", _PyCFunction_CAST(dict_setdefault), METH_FASTCALL, dict_setdefault__doc__},
static PyObject *
dict_setdefault_impl(PyDictObject *self, PyObject *key,
PyObject *default_value);
static PyObject *
dict_setdefault(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *key;
PyObject *default_value = Py_None;
if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) {
goto exit;
}
key = args[0];
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = dict_setdefault_impl(self, key, default_value);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
}
PyDoc_STRVAR(dict_clear__doc__,
"clear($self, /)\n"
"--\n"
"\n"
"Remove all items from the dict.");
#define DICT_CLEAR_METHODDEF \
{"clear", (PyCFunction)dict_clear, METH_NOARGS, dict_clear__doc__},
static PyObject *
dict_clear_impl(PyDictObject *self);
static PyObject *
dict_clear(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict_clear_impl(self);
}
PyDoc_STRVAR(dict_pop__doc__,
"pop($self, key, default=<unrepresentable>, /)\n"
"--\n"
"\n"
"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n"
"\n"
"If the key is not found, return the default if given; otherwise,\n"
"raise a KeyError.");
#define DICT_POP_METHODDEF \
{"pop", _PyCFunction_CAST(dict_pop), METH_FASTCALL, dict_pop__doc__},
static PyObject *
dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value);
static PyObject *
dict_pop(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *key;
PyObject *default_value = NULL;
if (!_PyArg_CheckPositional("pop", nargs, 1, 2)) {
goto exit;
}
key = args[0];
if (nargs < 2) {
goto skip_optional;
}
default_value = args[1];
skip_optional:
return_value = dict_pop_impl(self, key, default_value);
exit:
return return_value;
}
PyDoc_STRVAR(dict_popitem__doc__,
"popitem($self, /)\n"
"--\n"
"\n"
"Remove and return a (key, value) pair as a 2-tuple.\n"
"\n"
"Pairs are returned in LIFO (last-in, first-out) order.\n"
"Raises KeyError if the dict is empty.");
#define DICT_POPITEM_METHODDEF \
{"popitem", (PyCFunction)dict_popitem, METH_NOARGS, dict_popitem__doc__},
static PyObject *
dict_popitem_impl(PyDictObject *self);
static PyObject *
dict_popitem(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = dict_popitem_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(dict___sizeof____doc__,
"__sizeof__($self, /)\n"
"--\n"
"\n"
"Return the size of the dict in memory, in bytes.");
#define DICT___SIZEOF___METHODDEF \
{"__sizeof__", (PyCFunction)dict___sizeof__, METH_NOARGS, dict___sizeof____doc__},
static PyObject *
dict___sizeof___impl(PyDictObject *self);
static PyObject *
dict___sizeof__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict___sizeof___impl(self);
}
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);
}
PyDoc_STRVAR(dict_keys__doc__,
"keys($self, /)\n"
"--\n"
"\n"
"Return a set-like object providing a view on the dict\'s keys.");
#define DICT_KEYS_METHODDEF \
{"keys", (PyCFunction)dict_keys, METH_NOARGS, dict_keys__doc__},
static PyObject *
dict_keys_impl(PyDictObject *self);
static PyObject *
dict_keys(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict_keys_impl(self);
}
PyDoc_STRVAR(dict_items__doc__,
"items($self, /)\n"
"--\n"
"\n"
"Return a set-like object providing a view on the dict\'s items.");
#define DICT_ITEMS_METHODDEF \
{"items", (PyCFunction)dict_items, METH_NOARGS, dict_items__doc__},
static PyObject *
dict_items_impl(PyDictObject *self);
static PyObject *
dict_items(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict_items_impl(self);
}
PyDoc_STRVAR(dict_values__doc__,
"values($self, /)\n"
"--\n"
"\n"
"Return an object providing a view on the dict\'s values.");
#define DICT_VALUES_METHODDEF \
{"values", (PyCFunction)dict_values, METH_NOARGS, dict_values__doc__},
static PyObject *
dict_values_impl(PyDictObject *self);
static PyObject *
dict_values(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict_values_impl(self);
}
/*[clinic end generated code: output=f3dd5f3fb8122aef input=a9049054013a1b77]*/
|