1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | PyDoc_STRVAR(enum_new__doc__, |
6 | "enumerate(iterable, start=0)\n" |
7 | "--\n" |
8 | "\n" |
9 | "Return an enumerate object.\n" |
10 | "\n" |
11 | " iterable\n" |
12 | " an object supporting iteration\n" |
13 | "\n" |
14 | "The enumerate object yields pairs containing a count (from start, which\n" |
15 | "defaults to zero) and a value yielded by the iterable argument.\n" |
16 | "\n" |
17 | "enumerate is useful for obtaining an indexed list:\n" |
18 | " (0, seq[0]), (1, seq[1]), (2, seq[2]), ..." ); |
19 | |
20 | static PyObject * |
21 | enum_new_impl(PyTypeObject *type, PyObject *iterable, PyObject *start); |
22 | |
23 | static PyObject * |
24 | enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
25 | { |
26 | PyObject *return_value = NULL; |
27 | static const char * const _keywords[] = {"iterable" , "start" , NULL}; |
28 | static _PyArg_Parser _parser = {NULL, _keywords, "enumerate" , 0}; |
29 | PyObject *argsbuf[2]; |
30 | PyObject * const *fastargs; |
31 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
32 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
33 | PyObject *iterable; |
34 | PyObject *start = 0; |
35 | |
36 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); |
37 | if (!fastargs) { |
38 | goto exit; |
39 | } |
40 | iterable = fastargs[0]; |
41 | if (!noptargs) { |
42 | goto skip_optional_pos; |
43 | } |
44 | start = fastargs[1]; |
45 | skip_optional_pos: |
46 | return_value = enum_new_impl(type, iterable, start); |
47 | |
48 | exit: |
49 | return return_value; |
50 | } |
51 | |
52 | PyDoc_STRVAR(reversed_new__doc__, |
53 | "reversed(sequence, /)\n" |
54 | "--\n" |
55 | "\n" |
56 | "Return a reverse iterator over the values of the given sequence." ); |
57 | |
58 | static PyObject * |
59 | reversed_new_impl(PyTypeObject *type, PyObject *seq); |
60 | |
61 | static PyObject * |
62 | reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
63 | { |
64 | PyObject *return_value = NULL; |
65 | PyObject *seq; |
66 | |
67 | if ((type == &PyReversed_Type) && |
68 | !_PyArg_NoKeywords("reversed" , kwargs)) { |
69 | goto exit; |
70 | } |
71 | if (!_PyArg_CheckPositional("reversed" , PyTuple_GET_SIZE(args), 1, 1)) { |
72 | goto exit; |
73 | } |
74 | seq = PyTuple_GET_ITEM(args, 0); |
75 | return_value = reversed_new_impl(type, seq); |
76 | |
77 | exit: |
78 | return return_value; |
79 | } |
80 | /*[clinic end generated code: output=e18c3fefcf914ec7 input=a9049054013a1b77]*/ |
81 | |