1/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(tuple_index__doc__,
6"index($self, value, start=0, stop=sys.maxsize, /)\n"
7"--\n"
8"\n"
9"Return first index of value.\n"
10"\n"
11"Raises ValueError if the value is not present.");
12
13#define TUPLE_INDEX_METHODDEF \
14 {"index", (PyCFunction)(void(*)(void))tuple_index, METH_FASTCALL, tuple_index__doc__},
15
16static PyObject *
17tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start,
18 Py_ssize_t stop);
19
20static PyObject *
21tuple_index(PyTupleObject *self, PyObject *const *args, Py_ssize_t nargs)
22{
23 PyObject *return_value = NULL;
24 PyObject *value;
25 Py_ssize_t start = 0;
26 Py_ssize_t stop = PY_SSIZE_T_MAX;
27
28 if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
29 goto exit;
30 }
31 value = args[0];
32 if (nargs < 2) {
33 goto skip_optional;
34 }
35 if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
36 goto exit;
37 }
38 if (nargs < 3) {
39 goto skip_optional;
40 }
41 if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
42 goto exit;
43 }
44skip_optional:
45 return_value = tuple_index_impl(self, value, start, stop);
46
47exit:
48 return return_value;
49}
50
51PyDoc_STRVAR(tuple_count__doc__,
52"count($self, value, /)\n"
53"--\n"
54"\n"
55"Return number of occurrences of value.");
56
57#define TUPLE_COUNT_METHODDEF \
58 {"count", (PyCFunction)tuple_count, METH_O, tuple_count__doc__},
59
60PyDoc_STRVAR(tuple_new__doc__,
61"tuple(iterable=(), /)\n"
62"--\n"
63"\n"
64"Built-in immutable sequence.\n"
65"\n"
66"If no argument is given, the constructor returns an empty tuple.\n"
67"If iterable is specified the tuple is initialized from iterable\'s items.\n"
68"\n"
69"If the argument is a tuple, the return value is the same object.");
70
71static PyObject *
72tuple_new_impl(PyTypeObject *type, PyObject *iterable);
73
74static PyObject *
75tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
76{
77 PyObject *return_value = NULL;
78 PyObject *iterable = NULL;
79
80 if ((type == &PyTuple_Type) &&
81 !_PyArg_NoKeywords("tuple", kwargs)) {
82 goto exit;
83 }
84 if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) {
85 goto exit;
86 }
87 if (PyTuple_GET_SIZE(args) < 1) {
88 goto skip_optional;
89 }
90 iterable = PyTuple_GET_ITEM(args, 0);
91skip_optional:
92 return_value = tuple_new_impl(type, iterable);
93
94exit:
95 return return_value;
96}
97
98PyDoc_STRVAR(tuple___getnewargs____doc__,
99"__getnewargs__($self, /)\n"
100"--\n"
101"\n");
102
103#define TUPLE___GETNEWARGS___METHODDEF \
104 {"__getnewargs__", (PyCFunction)tuple___getnewargs__, METH_NOARGS, tuple___getnewargs____doc__},
105
106static PyObject *
107tuple___getnewargs___impl(PyTupleObject *self);
108
109static PyObject *
110tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored))
111{
112 return tuple___getnewargs___impl(self);
113}
114/*[clinic end generated code: output=56fab9b7368aba49 input=a9049054013a1b77]*/
115