/home/mdboom/Work/builds/cpython/Objects/clinic/tupleobject.c.h
Line | Count | Source (jump to first uncovered line) |
1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | PyDoc_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_CAST(tuple_index), METH_FASTCALL, tuple_index__doc__}, |
15 | |
16 | static PyObject * |
17 | tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start, |
18 | Py_ssize_t stop); |
19 | |
20 | static PyObject * |
21 | tuple_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) { Branch (32:9): [True: 782, False: 15]
|
33 | goto skip_optional; |
34 | } |
35 | if (!_PyEval_SliceIndexNotNone(args[1], &start)) { Branch (35:9): [True: 0, False: 15]
|
36 | goto exit; |
37 | } |
38 | if (nargs < 3) { Branch (38:9): [True: 8, False: 7]
|
39 | goto skip_optional; |
40 | } |
41 | if (!_PyEval_SliceIndexNotNone(args[2], &stop)) { Branch (41:9): [True: 0, False: 7]
|
42 | goto exit; |
43 | } |
44 | skip_optional: |
45 | return_value = tuple_index_impl(self, value, start, stop); |
46 | |
47 | exit: |
48 | return return_value; |
49 | } |
50 | |
51 | PyDoc_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 | |
60 | PyDoc_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 | |
71 | static PyObject * |
72 | tuple_new_impl(PyTypeObject *type, PyObject *iterable); |
73 | |
74 | static PyObject * |
75 | tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
76 | { |
77 | PyObject *return_value = NULL; |
78 | PyObject *iterable = NULL; |
79 | |
80 | if ((type == &PyTuple_Type || Branch (80:10): [True: 0, False: 1.01M]
|
81 | type->tp_init == PyTuple_Type.tp_init) && Branch (81:10): [True: 810k, False: 205k]
|
82 | !810k _PyArg_NoKeywords810k ("tuple", kwargs)) { |
83 | goto exit; |
84 | } |
85 | if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) { |
86 | goto exit; |
87 | } |
88 | if (PyTuple_GET_SIZE(args) < 1) { Branch (88:9): [True: 21, False: 1.01M]
|
89 | goto skip_optional; |
90 | } |
91 | iterable = PyTuple_GET_ITEM(args, 0); |
92 | skip_optional: |
93 | return_value = tuple_new_impl(type, iterable); |
94 | |
95 | exit: |
96 | return return_value; |
97 | } |
98 | |
99 | PyDoc_STRVAR(tuple___getnewargs____doc__, |
100 | "__getnewargs__($self, /)\n" |
101 | "--\n" |
102 | "\n"); |
103 | |
104 | #define TUPLE___GETNEWARGS___METHODDEF \ |
105 | {"__getnewargs__", (PyCFunction)tuple___getnewargs__, METH_NOARGS, tuple___getnewargs____doc__}, |
106 | |
107 | static PyObject * |
108 | tuple___getnewargs___impl(PyTupleObject *self); |
109 | |
110 | static PyObject * |
111 | tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored)) |
112 | { |
113 | return tuple___getnewargs___impl(self); |
114 | } |
115 | /*[clinic end generated code: output=044496dc917f8a97 input=a9049054013a1b77]*/ |