Serhiy Storchaka | 41baebd | 2017-01-19 18:48:17 +0200 | [diff] [blame] | 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 = {"O|O:enumerate", _keywords, 0}; |
| 29 | PyObject *iterable; |
| 30 | PyObject *start = 0; |
| 31 | |
| 32 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 33 | &iterable, &start)) { |
| 34 | goto exit; |
| 35 | } |
| 36 | return_value = enum_new_impl(type, iterable, start); |
| 37 | |
| 38 | exit: |
| 39 | return return_value; |
| 40 | } |
| 41 | |
| 42 | PyDoc_STRVAR(reversed_new__doc__, |
| 43 | "reversed(sequence, /)\n" |
| 44 | "--\n" |
| 45 | "\n" |
| 46 | "Return a reverse iterator over the values of the given sequence."); |
| 47 | |
| 48 | static PyObject * |
| 49 | reversed_new_impl(PyTypeObject *type, PyObject *seq); |
| 50 | |
| 51 | static PyObject * |
| 52 | reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 53 | { |
| 54 | PyObject *return_value = NULL; |
| 55 | PyObject *seq; |
| 56 | |
| 57 | if ((type == &PyReversed_Type) && |
| 58 | !_PyArg_NoKeywords("reversed", kwargs)) { |
| 59 | goto exit; |
| 60 | } |
| 61 | if (!PyArg_UnpackTuple(args, "reversed", |
| 62 | 1, 1, |
| 63 | &seq)) { |
| 64 | goto exit; |
| 65 | } |
| 66 | return_value = reversed_new_impl(type, seq); |
| 67 | |
| 68 | exit: |
| 69 | return return_value; |
| 70 | } |
| 71 | /*[clinic end generated code: output=9008c36999c57218 input=a9049054013a1b77]*/ |