Tal Einat | 3286ce4 | 2018-09-10 21:33:08 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(itertools_groupby__doc__, |
| 6 | "groupby(iterable, key=None)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "make an iterator that returns consecutive keys and groups from the iterable\n" |
| 10 | "\n" |
| 11 | " iterable\n" |
| 12 | " Elements to divide into groups according to the key function.\n" |
| 13 | " key\n" |
| 14 | " A function for computing the group category for each element.\n" |
| 15 | " If the key function is not specified or is None, the element itself\n" |
| 16 | " is used for grouping."); |
| 17 | |
| 18 | static PyObject * |
| 19 | itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc); |
| 20 | |
| 21 | static PyObject * |
| 22 | itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 23 | { |
| 24 | PyObject *return_value = NULL; |
| 25 | static const char * const _keywords[] = {"iterable", "key", NULL}; |
| 26 | static _PyArg_Parser _parser = {"O|O:groupby", _keywords, 0}; |
| 27 | PyObject *it; |
| 28 | PyObject *keyfunc = Py_None; |
| 29 | |
| 30 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 31 | &it, &keyfunc)) { |
| 32 | goto exit; |
| 33 | } |
| 34 | return_value = itertools_groupby_impl(type, it, keyfunc); |
| 35 | |
| 36 | exit: |
| 37 | return return_value; |
| 38 | } |
| 39 | |
| 40 | static PyObject * |
| 41 | itertools__grouper_impl(PyTypeObject *type, PyObject *parent, |
| 42 | PyObject *tgtkey); |
| 43 | |
| 44 | static PyObject * |
| 45 | itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 46 | { |
| 47 | PyObject *return_value = NULL; |
| 48 | PyObject *parent; |
| 49 | PyObject *tgtkey; |
| 50 | |
| 51 | if ((type == &_grouper_type) && |
| 52 | !_PyArg_NoKeywords("_grouper", kwargs)) { |
| 53 | goto exit; |
| 54 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 55 | if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) { |
Tal Einat | 3286ce4 | 2018-09-10 21:33:08 +0300 | [diff] [blame] | 56 | goto exit; |
| 57 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 58 | if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), &groupby_type)) { |
| 59 | _PyArg_BadArgument("_grouper", 1, (&groupby_type)->tp_name, PyTuple_GET_ITEM(args, 0)); |
| 60 | goto exit; |
| 61 | } |
| 62 | parent = PyTuple_GET_ITEM(args, 0); |
| 63 | tgtkey = PyTuple_GET_ITEM(args, 1); |
Tal Einat | 3286ce4 | 2018-09-10 21:33:08 +0300 | [diff] [blame] | 64 | return_value = itertools__grouper_impl(type, parent, tgtkey); |
| 65 | |
| 66 | exit: |
| 67 | return return_value; |
| 68 | } |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 69 | |
| 70 | PyDoc_STRVAR(itertools_teedataobject__doc__, |
| 71 | "teedataobject(iterable, values, next, /)\n" |
| 72 | "--\n" |
| 73 | "\n" |
| 74 | "Data container common to multiple tee objects."); |
| 75 | |
| 76 | static PyObject * |
| 77 | itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, |
| 78 | PyObject *values, PyObject *next); |
| 79 | |
| 80 | static PyObject * |
| 81 | itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 82 | { |
| 83 | PyObject *return_value = NULL; |
| 84 | PyObject *it; |
| 85 | PyObject *values; |
| 86 | PyObject *next; |
| 87 | |
| 88 | if ((type == &teedataobject_type) && |
| 89 | !_PyArg_NoKeywords("teedataobject", kwargs)) { |
| 90 | goto exit; |
| 91 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 92 | if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) { |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 93 | goto exit; |
| 94 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 95 | it = PyTuple_GET_ITEM(args, 0); |
| 96 | if (!PyList_Check(PyTuple_GET_ITEM(args, 1))) { |
| 97 | _PyArg_BadArgument("teedataobject", 2, "list", PyTuple_GET_ITEM(args, 1)); |
| 98 | goto exit; |
| 99 | } |
| 100 | values = PyTuple_GET_ITEM(args, 1); |
| 101 | next = PyTuple_GET_ITEM(args, 2); |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 102 | return_value = itertools_teedataobject_impl(type, it, values, next); |
| 103 | |
| 104 | exit: |
| 105 | return return_value; |
| 106 | } |
| 107 | |
| 108 | PyDoc_STRVAR(itertools__tee__doc__, |
| 109 | "_tee(iterable, /)\n" |
| 110 | "--\n" |
| 111 | "\n" |
| 112 | "Iterator wrapped to make it copyable."); |
| 113 | |
| 114 | static PyObject * |
| 115 | itertools__tee_impl(PyTypeObject *type, PyObject *iterable); |
| 116 | |
| 117 | static PyObject * |
| 118 | itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 119 | { |
| 120 | PyObject *return_value = NULL; |
| 121 | PyObject *iterable; |
| 122 | |
| 123 | if ((type == &tee_type) && |
| 124 | !_PyArg_NoKeywords("_tee", kwargs)) { |
| 125 | goto exit; |
| 126 | } |
| 127 | if (!PyArg_UnpackTuple(args, "_tee", |
| 128 | 1, 1, |
| 129 | &iterable)) { |
| 130 | goto exit; |
| 131 | } |
| 132 | return_value = itertools__tee_impl(type, iterable); |
| 133 | |
| 134 | exit: |
| 135 | return return_value; |
| 136 | } |
| 137 | |
| 138 | PyDoc_STRVAR(itertools_tee__doc__, |
| 139 | "tee($module, iterable, n=2, /)\n" |
| 140 | "--\n" |
| 141 | "\n" |
| 142 | "Returns a tuple of n independent iterators."); |
| 143 | |
| 144 | #define ITERTOOLS_TEE_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 145 | {"tee", (PyCFunction)(void(*)(void))itertools_tee, METH_FASTCALL, itertools_tee__doc__}, |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 146 | |
| 147 | static PyObject * |
| 148 | itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n); |
| 149 | |
| 150 | static PyObject * |
| 151 | itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 152 | { |
| 153 | PyObject *return_value = NULL; |
| 154 | PyObject *iterable; |
| 155 | Py_ssize_t n = 2; |
| 156 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 157 | if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) { |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 158 | goto exit; |
| 159 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 160 | iterable = args[0]; |
| 161 | if (nargs < 2) { |
| 162 | goto skip_optional; |
| 163 | } |
| 164 | if (PyFloat_Check(args[1])) { |
| 165 | PyErr_SetString(PyExc_TypeError, |
| 166 | "integer argument expected, got float" ); |
| 167 | goto exit; |
| 168 | } |
| 169 | { |
| 170 | Py_ssize_t ival = -1; |
| 171 | PyObject *iobj = PyNumber_Index(args[1]); |
| 172 | if (iobj != NULL) { |
| 173 | ival = PyLong_AsSsize_t(iobj); |
| 174 | Py_DECREF(iobj); |
| 175 | } |
| 176 | if (ival == -1 && PyErr_Occurred()) { |
| 177 | goto exit; |
| 178 | } |
| 179 | n = ival; |
| 180 | } |
| 181 | skip_optional: |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 182 | return_value = itertools_tee_impl(module, iterable, n); |
| 183 | |
| 184 | exit: |
| 185 | return return_value; |
| 186 | } |
| 187 | |
| 188 | PyDoc_STRVAR(itertools_cycle__doc__, |
| 189 | "cycle(iterable, /)\n" |
| 190 | "--\n" |
| 191 | "\n" |
| 192 | "Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."); |
| 193 | |
| 194 | static PyObject * |
| 195 | itertools_cycle_impl(PyTypeObject *type, PyObject *iterable); |
| 196 | |
| 197 | static PyObject * |
| 198 | itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 199 | { |
| 200 | PyObject *return_value = NULL; |
| 201 | PyObject *iterable; |
| 202 | |
| 203 | if ((type == &cycle_type) && |
| 204 | !_PyArg_NoKeywords("cycle", kwargs)) { |
| 205 | goto exit; |
| 206 | } |
| 207 | if (!PyArg_UnpackTuple(args, "cycle", |
| 208 | 1, 1, |
| 209 | &iterable)) { |
| 210 | goto exit; |
| 211 | } |
| 212 | return_value = itertools_cycle_impl(type, iterable); |
| 213 | |
| 214 | exit: |
| 215 | return return_value; |
| 216 | } |
| 217 | |
| 218 | PyDoc_STRVAR(itertools_dropwhile__doc__, |
| 219 | "dropwhile(predicate, iterable, /)\n" |
| 220 | "--\n" |
| 221 | "\n" |
| 222 | "Drop items from the iterable while predicate(item) is true.\n" |
| 223 | "\n" |
| 224 | "Afterwards, return every element until the iterable is exhausted."); |
| 225 | |
| 226 | static PyObject * |
| 227 | itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
| 228 | |
| 229 | static PyObject * |
| 230 | itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 231 | { |
| 232 | PyObject *return_value = NULL; |
| 233 | PyObject *func; |
| 234 | PyObject *seq; |
| 235 | |
| 236 | if ((type == &dropwhile_type) && |
| 237 | !_PyArg_NoKeywords("dropwhile", kwargs)) { |
| 238 | goto exit; |
| 239 | } |
| 240 | if (!PyArg_UnpackTuple(args, "dropwhile", |
| 241 | 2, 2, |
| 242 | &func, &seq)) { |
| 243 | goto exit; |
| 244 | } |
| 245 | return_value = itertools_dropwhile_impl(type, func, seq); |
| 246 | |
| 247 | exit: |
| 248 | return return_value; |
| 249 | } |
| 250 | |
| 251 | PyDoc_STRVAR(itertools_takewhile__doc__, |
| 252 | "takewhile(predicate, iterable, /)\n" |
| 253 | "--\n" |
| 254 | "\n" |
| 255 | "Return successive entries from an iterable as long as the predicate evaluates to true for each entry."); |
| 256 | |
| 257 | static PyObject * |
| 258 | itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
| 259 | |
| 260 | static PyObject * |
| 261 | itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 262 | { |
| 263 | PyObject *return_value = NULL; |
| 264 | PyObject *func; |
| 265 | PyObject *seq; |
| 266 | |
| 267 | if ((type == &takewhile_type) && |
| 268 | !_PyArg_NoKeywords("takewhile", kwargs)) { |
| 269 | goto exit; |
| 270 | } |
| 271 | if (!PyArg_UnpackTuple(args, "takewhile", |
| 272 | 2, 2, |
| 273 | &func, &seq)) { |
| 274 | goto exit; |
| 275 | } |
| 276 | return_value = itertools_takewhile_impl(type, func, seq); |
| 277 | |
| 278 | exit: |
| 279 | return return_value; |
| 280 | } |
| 281 | |
| 282 | PyDoc_STRVAR(itertools_starmap__doc__, |
| 283 | "starmap(function, iterable, /)\n" |
| 284 | "--\n" |
| 285 | "\n" |
| 286 | "Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."); |
| 287 | |
| 288 | static PyObject * |
| 289 | itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
| 290 | |
| 291 | static PyObject * |
| 292 | itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 293 | { |
| 294 | PyObject *return_value = NULL; |
| 295 | PyObject *func; |
| 296 | PyObject *seq; |
| 297 | |
| 298 | if ((type == &starmap_type) && |
| 299 | !_PyArg_NoKeywords("starmap", kwargs)) { |
| 300 | goto exit; |
| 301 | } |
| 302 | if (!PyArg_UnpackTuple(args, "starmap", |
| 303 | 2, 2, |
| 304 | &func, &seq)) { |
| 305 | goto exit; |
| 306 | } |
| 307 | return_value = itertools_starmap_impl(type, func, seq); |
| 308 | |
| 309 | exit: |
| 310 | return return_value; |
| 311 | } |
| 312 | |
| 313 | PyDoc_STRVAR(itertools_chain_from_iterable__doc__, |
| 314 | "from_iterable($type, iterable, /)\n" |
| 315 | "--\n" |
| 316 | "\n" |
| 317 | "Alternative chain() constructor taking a single iterable argument that evaluates lazily."); |
| 318 | |
| 319 | #define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \ |
| 320 | {"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__}, |
| 321 | |
| 322 | PyDoc_STRVAR(itertools_combinations__doc__, |
| 323 | "combinations(iterable, r)\n" |
| 324 | "--\n" |
| 325 | "\n" |
| 326 | "Return successive r-length combinations of elements in the iterable.\n" |
| 327 | "\n" |
| 328 | "combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"); |
| 329 | |
| 330 | static PyObject * |
| 331 | itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, |
| 332 | Py_ssize_t r); |
| 333 | |
| 334 | static PyObject * |
| 335 | itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 336 | { |
| 337 | PyObject *return_value = NULL; |
| 338 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
| 339 | static _PyArg_Parser _parser = {"On:combinations", _keywords, 0}; |
| 340 | PyObject *iterable; |
| 341 | Py_ssize_t r; |
| 342 | |
| 343 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 344 | &iterable, &r)) { |
| 345 | goto exit; |
| 346 | } |
| 347 | return_value = itertools_combinations_impl(type, iterable, r); |
| 348 | |
| 349 | exit: |
| 350 | return return_value; |
| 351 | } |
| 352 | |
| 353 | PyDoc_STRVAR(itertools_combinations_with_replacement__doc__, |
| 354 | "combinations_with_replacement(iterable, r)\n" |
| 355 | "--\n" |
| 356 | "\n" |
| 357 | "Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.\n" |
| 358 | "\n" |
| 359 | "combinations_with_replacement(\'ABC\', 2) --> AA AB AC BB BC CC\""); |
| 360 | |
| 361 | static PyObject * |
| 362 | itertools_combinations_with_replacement_impl(PyTypeObject *type, |
| 363 | PyObject *iterable, |
| 364 | Py_ssize_t r); |
| 365 | |
| 366 | static PyObject * |
| 367 | itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 368 | { |
| 369 | PyObject *return_value = NULL; |
| 370 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
| 371 | static _PyArg_Parser _parser = {"On:combinations_with_replacement", _keywords, 0}; |
| 372 | PyObject *iterable; |
| 373 | Py_ssize_t r; |
| 374 | |
| 375 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 376 | &iterable, &r)) { |
| 377 | goto exit; |
| 378 | } |
| 379 | return_value = itertools_combinations_with_replacement_impl(type, iterable, r); |
| 380 | |
| 381 | exit: |
| 382 | return return_value; |
| 383 | } |
| 384 | |
| 385 | PyDoc_STRVAR(itertools_permutations__doc__, |
| 386 | "permutations(iterable, r=None)\n" |
| 387 | "--\n" |
| 388 | "\n" |
| 389 | "Return successive r-length permutations of elements in the iterable.\n" |
| 390 | "\n" |
| 391 | "permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"); |
| 392 | |
| 393 | static PyObject * |
| 394 | itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, |
| 395 | PyObject *robj); |
| 396 | |
| 397 | static PyObject * |
| 398 | itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 399 | { |
| 400 | PyObject *return_value = NULL; |
| 401 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
| 402 | static _PyArg_Parser _parser = {"O|O:permutations", _keywords, 0}; |
| 403 | PyObject *iterable; |
| 404 | PyObject *robj = Py_None; |
| 405 | |
| 406 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 407 | &iterable, &robj)) { |
| 408 | goto exit; |
| 409 | } |
| 410 | return_value = itertools_permutations_impl(type, iterable, robj); |
| 411 | |
| 412 | exit: |
| 413 | return return_value; |
| 414 | } |
| 415 | |
| 416 | PyDoc_STRVAR(itertools_accumulate__doc__, |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 417 | "accumulate(iterable, func=None, *, initial=None)\n" |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 418 | "--\n" |
| 419 | "\n" |
| 420 | "Return series of accumulated sums (or other binary function results)."); |
| 421 | |
| 422 | static PyObject * |
| 423 | itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 424 | PyObject *binop, PyObject *initial); |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 425 | |
| 426 | static PyObject * |
| 427 | itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 428 | { |
| 429 | PyObject *return_value = NULL; |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 430 | static const char * const _keywords[] = {"iterable", "func", "initial", NULL}; |
| 431 | static _PyArg_Parser _parser = {"O|O$O:accumulate", _keywords, 0}; |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 432 | PyObject *iterable; |
| 433 | PyObject *binop = Py_None; |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 434 | PyObject *initial = Py_None; |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 435 | |
| 436 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 437 | &iterable, &binop, &initial)) { |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 438 | goto exit; |
| 439 | } |
Lisa Roach | 9718b59 | 2018-09-23 17:34:59 -0700 | [diff] [blame] | 440 | return_value = itertools_accumulate_impl(type, iterable, binop, initial); |
Tal Einat | c4bccd3 | 2018-09-12 00:49:13 +0300 | [diff] [blame] | 441 | |
| 442 | exit: |
| 443 | return return_value; |
| 444 | } |
| 445 | |
| 446 | PyDoc_STRVAR(itertools_compress__doc__, |
| 447 | "compress(data, selectors)\n" |
| 448 | "--\n" |
| 449 | "\n" |
| 450 | "Return data elements corresponding to true selector elements.\n" |
| 451 | "\n" |
| 452 | "Forms a shorter iterator from selected data elements using the selectors to\n" |
| 453 | "choose the data elements."); |
| 454 | |
| 455 | static PyObject * |
| 456 | itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2); |
| 457 | |
| 458 | static PyObject * |
| 459 | itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 460 | { |
| 461 | PyObject *return_value = NULL; |
| 462 | static const char * const _keywords[] = {"data", "selectors", NULL}; |
| 463 | static _PyArg_Parser _parser = {"OO:compress", _keywords, 0}; |
| 464 | PyObject *seq1; |
| 465 | PyObject *seq2; |
| 466 | |
| 467 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 468 | &seq1, &seq2)) { |
| 469 | goto exit; |
| 470 | } |
| 471 | return_value = itertools_compress_impl(type, seq1, seq2); |
| 472 | |
| 473 | exit: |
| 474 | return return_value; |
| 475 | } |
| 476 | |
| 477 | PyDoc_STRVAR(itertools_filterfalse__doc__, |
| 478 | "filterfalse(function, iterable, /)\n" |
| 479 | "--\n" |
| 480 | "\n" |
| 481 | "Return those items of iterable for which function(item) is false.\n" |
| 482 | "\n" |
| 483 | "If function is None, return the items that are false."); |
| 484 | |
| 485 | static PyObject * |
| 486 | itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
| 487 | |
| 488 | static PyObject * |
| 489 | itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 490 | { |
| 491 | PyObject *return_value = NULL; |
| 492 | PyObject *func; |
| 493 | PyObject *seq; |
| 494 | |
| 495 | if ((type == &filterfalse_type) && |
| 496 | !_PyArg_NoKeywords("filterfalse", kwargs)) { |
| 497 | goto exit; |
| 498 | } |
| 499 | if (!PyArg_UnpackTuple(args, "filterfalse", |
| 500 | 2, 2, |
| 501 | &func, &seq)) { |
| 502 | goto exit; |
| 503 | } |
| 504 | return_value = itertools_filterfalse_impl(type, func, seq); |
| 505 | |
| 506 | exit: |
| 507 | return return_value; |
| 508 | } |
| 509 | |
| 510 | PyDoc_STRVAR(itertools_count__doc__, |
| 511 | "count(start=0, step=1)\n" |
| 512 | "--\n" |
| 513 | "\n" |
| 514 | "Return a count object whose .__next__() method returns consecutive values.\n" |
| 515 | "\n" |
| 516 | "Equivalent to:\n" |
| 517 | " def count(firstval=0, step=1):\n" |
| 518 | " x = firstval\n" |
| 519 | " while 1:\n" |
| 520 | " yield x\n" |
| 521 | " x += step"); |
| 522 | |
| 523 | static PyObject * |
| 524 | itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, |
| 525 | PyObject *long_step); |
| 526 | |
| 527 | static PyObject * |
| 528 | itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 529 | { |
| 530 | PyObject *return_value = NULL; |
| 531 | static const char * const _keywords[] = {"start", "step", NULL}; |
| 532 | static _PyArg_Parser _parser = {"|OO:count", _keywords, 0}; |
| 533 | PyObject *long_cnt = NULL; |
| 534 | PyObject *long_step = NULL; |
| 535 | |
| 536 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
| 537 | &long_cnt, &long_step)) { |
| 538 | goto exit; |
| 539 | } |
| 540 | return_value = itertools_count_impl(type, long_cnt, long_step); |
| 541 | |
| 542 | exit: |
| 543 | return return_value; |
| 544 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame^] | 545 | /*[clinic end generated code: output=f289354f54e04c13 input=a9049054013a1b77]*/ |