1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9
10
11 PyDoc_STRVAR(_collections__count_elements__doc__,
12 "_count_elements($module, mapping, iterable, /)\n"
13 "--\n"
14 "\n"
15 "Count elements in the iterable, updating the mapping");
16
17 #define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF \
18 {"_count_elements", _PyCFunction_CAST(_collections__count_elements), METH_FASTCALL, _collections__count_elements__doc__},
19
20 static PyObject *
21 _collections__count_elements_impl(PyObject *module, PyObject *mapping,
22 PyObject *iterable);
23
24 static PyObject *
25 _collections__count_elements(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
26 {
27 PyObject *return_value = NULL;
28 PyObject *mapping;
29 PyObject *iterable;
30
31 if (!_PyArg_CheckPositional("_count_elements", nargs, 2, 2)) {
32 goto exit;
33 }
34 mapping = args[0];
35 iterable = args[1];
36 return_value = _collections__count_elements_impl(module, mapping, iterable);
37
38 exit:
39 return return_value;
40 }
41
42 static PyObject *
43 tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc);
44
45 static PyObject *
46 tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
47 {
48 PyObject *return_value = NULL;
49 PyTypeObject *base_tp = clinic_state()->tuplegetter_type;
50 Py_ssize_t index;
51 PyObject *doc;
52
53 if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
54 !_PyArg_NoKeywords("_tuplegetter", kwargs)) {
55 goto exit;
56 }
57 if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
58 goto exit;
59 }
60 {
61 Py_ssize_t ival = -1;
62 PyObject *iobj = _PyNumber_Index(PyTuple_GET_ITEM(args, 0));
63 if (iobj != NULL) {
64 ival = PyLong_AsSsize_t(iobj);
65 Py_DECREF(iobj);
66 }
67 if (ival == -1 && PyErr_Occurred()) {
68 goto exit;
69 }
70 index = ival;
71 }
72 doc = PyTuple_GET_ITEM(args, 1);
73 return_value = tuplegetter_new_impl(type, index, doc);
74
75 exit:
76 return return_value;
77 }
78 /*[clinic end generated code: output=00e516317d2b8bed input=a9049054013a1b77]*/