/home/mdboom/Work/builds/cpython/Modules/clinic/itertoolsmodule.c.h
Line | Count | Source (jump to first uncovered line) |
1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | PyDoc_STRVAR(pairwise_new__doc__, |
6 | "pairwise(iterable, /)\n" |
7 | "--\n" |
8 | "\n" |
9 | "Return an iterator of overlapping pairs taken from the input iterator.\n" |
10 | "\n" |
11 | " s -> (s0,s1), (s1,s2), (s2, s3), ..."); |
12 | |
13 | static PyObject * |
14 | pairwise_new_impl(PyTypeObject *type, PyObject *iterable); |
15 | |
16 | static PyObject * |
17 | pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
18 | { |
19 | PyObject *return_value = NULL; |
20 | PyObject *iterable; |
21 | |
22 | if ((type == &pairwise_type || Branch (22:10): [True: 55, False: 0]
|
23 | type->tp_init == pairwise_type.tp_init0 ) && Branch (23:10): [True: 0, False: 0]
|
24 | !_PyArg_NoKeywords("pairwise", kwargs)) { |
25 | goto exit; |
26 | } |
27 | if (!_PyArg_CheckPositional("pairwise", PyTuple_GET_SIZE(args), 1, 1)) { |
28 | goto exit; |
29 | } |
30 | iterable = PyTuple_GET_ITEM(args, 0); |
31 | return_value = pairwise_new_impl(type, iterable); |
32 | |
33 | exit: |
34 | return return_value; |
35 | } |
36 | |
37 | PyDoc_STRVAR(itertools_groupby__doc__, |
38 | "groupby(iterable, key=None)\n" |
39 | "--\n" |
40 | "\n" |
41 | "make an iterator that returns consecutive keys and groups from the iterable\n" |
42 | "\n" |
43 | " iterable\n" |
44 | " Elements to divide into groups according to the key function.\n" |
45 | " key\n" |
46 | " A function for computing the group category for each element.\n" |
47 | " If the key function is not specified or is None, the element itself\n" |
48 | " is used for grouping."); |
49 | |
50 | static PyObject * |
51 | itertools_groupby_impl(PyTypeObject *type, PyObject *it, PyObject *keyfunc); |
52 | |
53 | static PyObject * |
54 | itertools_groupby(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
55 | { |
56 | PyObject *return_value = NULL; |
57 | static const char * const _keywords[] = {"iterable", "key", NULL}; |
58 | static _PyArg_Parser _parser = {NULL, _keywords, "groupby", 0}; |
59 | PyObject *argsbuf[2]; |
60 | PyObject * const *fastargs; |
61 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
62 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE14 (kwargs) : 03.00k ) - 1; Branch (62:36): [True: 14, False: 3.00k]
|
63 | PyObject *it; |
64 | PyObject *keyfunc = Py_None; |
65 | |
66 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); |
67 | if (!fastargs) { Branch (67:9): [True: 1, False: 3.02k]
|
68 | goto exit; |
69 | } |
70 | it = fastargs[0]; |
71 | if (!noptargs) { Branch (71:9): [True: 2.40k, False: 613]
|
72 | goto skip_optional_pos; |
73 | } |
74 | keyfunc = fastargs[1]; |
75 | skip_optional_pos: |
76 | return_value = itertools_groupby_impl(type, it, keyfunc); |
77 | |
78 | exit: |
79 | return return_value; |
80 | } |
81 | |
82 | static PyObject * |
83 | itertools__grouper_impl(PyTypeObject *type, PyObject *parent, |
84 | PyObject *tgtkey); |
85 | |
86 | static PyObject * |
87 | itertools__grouper(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
88 | { |
89 | PyObject *return_value = NULL; |
90 | PyObject *parent; |
91 | PyObject *tgtkey; |
92 | |
93 | if ((type == &_grouper_type || Branch (93:10): [True: 24, False: 0]
|
94 | type->tp_init == _grouper_type.tp_init0 ) && Branch (94:10): [True: 0, False: 0]
|
95 | !_PyArg_NoKeywords("_grouper", kwargs)) { |
96 | goto exit; |
97 | } |
98 | if (!_PyArg_CheckPositional("_grouper", PyTuple_GET_SIZE(args), 2, 2)) { |
99 | goto exit; |
100 | } |
101 | if (!PyObject_TypeCheck(PyTuple_GET_ITEM(args, 0), &groupby_type)) { Branch (101:9): [True: 0, False: 24]
|
102 | _PyArg_BadArgument("_grouper", "argument 1", (&groupby_type)->tp_name, PyTuple_GET_ITEM(args, 0)); |
103 | goto exit; |
104 | } |
105 | parent = PyTuple_GET_ITEM(args, 0); |
106 | tgtkey = PyTuple_GET_ITEM(args, 1); |
107 | return_value = itertools__grouper_impl(type, parent, tgtkey); |
108 | |
109 | exit: |
110 | return return_value; |
111 | } |
112 | |
113 | PyDoc_STRVAR(itertools_teedataobject__doc__, |
114 | "teedataobject(iterable, values, next, /)\n" |
115 | "--\n" |
116 | "\n" |
117 | "Data container common to multiple tee objects."); |
118 | |
119 | static PyObject * |
120 | itertools_teedataobject_impl(PyTypeObject *type, PyObject *it, |
121 | PyObject *values, PyObject *next); |
122 | |
123 | static PyObject * |
124 | itertools_teedataobject(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
125 | { |
126 | PyObject *return_value = NULL; |
127 | PyObject *it; |
128 | PyObject *values; |
129 | PyObject *next; |
130 | |
131 | if ((type == &teedataobject_type || Branch (131:10): [True: 62, False: 0]
|
132 | type->tp_init == teedataobject_type.tp_init0 ) && Branch (132:10): [True: 0, False: 0]
|
133 | !_PyArg_NoKeywords("teedataobject", kwargs)) { |
134 | goto exit; |
135 | } |
136 | if (!_PyArg_CheckPositional("teedataobject", PyTuple_GET_SIZE(args), 3, 3)) { |
137 | goto exit; |
138 | } |
139 | it = PyTuple_GET_ITEM(args, 0); |
140 | if (!PyList_Check(PyTuple_GET_ITEM(args, 1))) { Branch (140:9): [True: 0, False: 62]
|
141 | _PyArg_BadArgument("teedataobject", "argument 2", "list", PyTuple_GET_ITEM(args, 1)); |
142 | goto exit; |
143 | } |
144 | values = PyTuple_GET_ITEM(args, 1); |
145 | next = PyTuple_GET_ITEM(args, 2); |
146 | return_value = itertools_teedataobject_impl(type, it, values, next); |
147 | |
148 | exit: |
149 | return return_value; |
150 | } |
151 | |
152 | PyDoc_STRVAR(itertools__tee__doc__, |
153 | "_tee(iterable, /)\n" |
154 | "--\n" |
155 | "\n" |
156 | "Iterator wrapped to make it copyable."); |
157 | |
158 | static PyObject * |
159 | itertools__tee_impl(PyTypeObject *type, PyObject *iterable); |
160 | |
161 | static PyObject * |
162 | itertools__tee(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
163 | { |
164 | PyObject *return_value = NULL; |
165 | PyObject *iterable; |
166 | |
167 | if ((type == &tee_type || Branch (167:10): [True: 84, False: 0]
|
168 | type->tp_init == tee_type.tp_init0 ) && Branch (168:10): [True: 0, False: 0]
|
169 | !_PyArg_NoKeywords("_tee", kwargs)) { |
170 | goto exit; |
171 | } |
172 | if (!_PyArg_CheckPositional("_tee", PyTuple_GET_SIZE(args), 1, 1)) { |
173 | goto exit; |
174 | } |
175 | iterable = PyTuple_GET_ITEM(args, 0); |
176 | return_value = itertools__tee_impl(type, iterable); |
177 | |
178 | exit: |
179 | return return_value; |
180 | } |
181 | |
182 | PyDoc_STRVAR(itertools_tee__doc__, |
183 | "tee($module, iterable, n=2, /)\n" |
184 | "--\n" |
185 | "\n" |
186 | "Returns a tuple of n independent iterators."); |
187 | |
188 | #define ITERTOOLS_TEE_METHODDEF \ |
189 | {"tee", _PyCFunction_CAST(itertools_tee), METH_FASTCALL, itertools_tee__doc__}, |
190 | |
191 | static PyObject * |
192 | itertools_tee_impl(PyObject *module, PyObject *iterable, Py_ssize_t n); |
193 | |
194 | static PyObject * |
195 | itertools_tee(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
196 | { |
197 | PyObject *return_value = NULL; |
198 | PyObject *iterable; |
199 | Py_ssize_t n = 2; |
200 | |
201 | if (!_PyArg_CheckPositional("tee", nargs, 1, 2)) { |
202 | goto exit; |
203 | } |
204 | iterable = args[0]; |
205 | if (nargs < 2) { Branch (205:9): [True: 95, False: 11]
|
206 | goto skip_optional; |
207 | } |
208 | { |
209 | Py_ssize_t ival = -1; |
210 | PyObject *iobj = _PyNumber_Index(args[1]); |
211 | if (iobj != NULL) { Branch (211:13): [True: 9, False: 2]
|
212 | ival = PyLong_AsSsize_t(iobj); |
213 | Py_DECREF(iobj); |
214 | } |
215 | if (ival == -1 && PyErr_Occurred()3 ) { Branch (215:13): [True: 3, False: 8]
Branch (215:27): [True: 2, False: 1]
|
216 | goto exit; |
217 | } |
218 | n = ival; |
219 | } |
220 | skip_optional: |
221 | return_value = itertools_tee_impl(module, iterable, n); |
222 | |
223 | exit: |
224 | return return_value; |
225 | } |
226 | |
227 | PyDoc_STRVAR(itertools_cycle__doc__, |
228 | "cycle(iterable, /)\n" |
229 | "--\n" |
230 | "\n" |
231 | "Return elements from the iterable until it is exhausted. Then repeat the sequence indefinitely."); |
232 | |
233 | static PyObject * |
234 | itertools_cycle_impl(PyTypeObject *type, PyObject *iterable); |
235 | |
236 | static PyObject * |
237 | itertools_cycle(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
238 | { |
239 | PyObject *return_value = NULL; |
240 | PyObject *iterable; |
241 | |
242 | if ((type == &cycle_type || Branch (242:10): [True: 130, False: 4]
|
243 | type->tp_init == cycle_type.tp_init4 ) && Branch (243:10): [True: 3, False: 1]
|
244 | !133 _PyArg_NoKeywords133 ("cycle", kwargs)) { |
245 | goto exit; |
246 | } |
247 | if (!_PyArg_CheckPositional("cycle", PyTuple_GET_SIZE(args), 1, 1)) { |
248 | goto exit; |
249 | } |
250 | iterable = PyTuple_GET_ITEM(args, 0); |
251 | return_value = itertools_cycle_impl(type, iterable); |
252 | |
253 | exit: |
254 | return return_value; |
255 | } |
256 | |
257 | PyDoc_STRVAR(itertools_dropwhile__doc__, |
258 | "dropwhile(predicate, iterable, /)\n" |
259 | "--\n" |
260 | "\n" |
261 | "Drop items from the iterable while predicate(item) is true.\n" |
262 | "\n" |
263 | "Afterwards, return every element until the iterable is exhausted."); |
264 | |
265 | static PyObject * |
266 | itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
267 | |
268 | static PyObject * |
269 | itertools_dropwhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
270 | { |
271 | PyObject *return_value = NULL; |
272 | PyObject *func; |
273 | PyObject *seq; |
274 | |
275 | if ((type == &dropwhile_type || Branch (275:10): [True: 84, False: 4]
|
276 | type->tp_init == dropwhile_type.tp_init4 ) && Branch (276:10): [True: 3, False: 1]
|
277 | !87 _PyArg_NoKeywords87 ("dropwhile", kwargs)) { |
278 | goto exit; |
279 | } |
280 | if (!_PyArg_CheckPositional("dropwhile", PyTuple_GET_SIZE(args), 2, 2)) { |
281 | goto exit; |
282 | } |
283 | func = PyTuple_GET_ITEM(args, 0); |
284 | seq = PyTuple_GET_ITEM(args, 1); |
285 | return_value = itertools_dropwhile_impl(type, func, seq); |
286 | |
287 | exit: |
288 | return return_value; |
289 | } |
290 | |
291 | PyDoc_STRVAR(itertools_takewhile__doc__, |
292 | "takewhile(predicate, iterable, /)\n" |
293 | "--\n" |
294 | "\n" |
295 | "Return successive entries from an iterable as long as the predicate evaluates to true for each entry."); |
296 | |
297 | static PyObject * |
298 | itertools_takewhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
299 | |
300 | static PyObject * |
301 | itertools_takewhile(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
302 | { |
303 | PyObject *return_value = NULL; |
304 | PyObject *func; |
305 | PyObject *seq; |
306 | |
307 | if ((type == &takewhile_type || Branch (307:10): [True: 86, False: 4]
|
308 | type->tp_init == takewhile_type.tp_init4 ) && Branch (308:10): [True: 3, False: 1]
|
309 | !89 _PyArg_NoKeywords89 ("takewhile", kwargs)) { |
310 | goto exit; |
311 | } |
312 | if (!_PyArg_CheckPositional("takewhile", PyTuple_GET_SIZE(args), 2, 2)) { |
313 | goto exit; |
314 | } |
315 | func = PyTuple_GET_ITEM(args, 0); |
316 | seq = PyTuple_GET_ITEM(args, 1); |
317 | return_value = itertools_takewhile_impl(type, func, seq); |
318 | |
319 | exit: |
320 | return return_value; |
321 | } |
322 | |
323 | PyDoc_STRVAR(itertools_starmap__doc__, |
324 | "starmap(function, iterable, /)\n" |
325 | "--\n" |
326 | "\n" |
327 | "Return an iterator whose values are returned from the function evaluated with an argument tuple taken from the given sequence."); |
328 | |
329 | static PyObject * |
330 | itertools_starmap_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
331 | |
332 | static PyObject * |
333 | itertools_starmap(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
334 | { |
335 | PyObject *return_value = NULL; |
336 | PyObject *func; |
337 | PyObject *seq; |
338 | |
339 | if ((type == &starmap_type || Branch (339:10): [True: 9.01k, False: 4]
|
340 | type->tp_init == starmap_type.tp_init4 ) && Branch (340:10): [True: 3, False: 1]
|
341 | !9.01k _PyArg_NoKeywords9.01k ("starmap", kwargs)) { |
342 | goto exit; |
343 | } |
344 | if (!_PyArg_CheckPositional("starmap", PyTuple_GET_SIZE(args), 2, 2)) { |
345 | goto exit; |
346 | } |
347 | func = PyTuple_GET_ITEM(args, 0); |
348 | seq = PyTuple_GET_ITEM(args, 1); |
349 | return_value = itertools_starmap_impl(type, func, seq); |
350 | |
351 | exit: |
352 | return return_value; |
353 | } |
354 | |
355 | PyDoc_STRVAR(itertools_chain_from_iterable__doc__, |
356 | "from_iterable($type, iterable, /)\n" |
357 | "--\n" |
358 | "\n" |
359 | "Alternative chain() constructor taking a single iterable argument that evaluates lazily."); |
360 | |
361 | #define ITERTOOLS_CHAIN_FROM_ITERABLE_METHODDEF \ |
362 | {"from_iterable", (PyCFunction)itertools_chain_from_iterable, METH_O|METH_CLASS, itertools_chain_from_iterable__doc__}, |
363 | |
364 | PyDoc_STRVAR(itertools_combinations__doc__, |
365 | "combinations(iterable, r)\n" |
366 | "--\n" |
367 | "\n" |
368 | "Return successive r-length combinations of elements in the iterable.\n" |
369 | "\n" |
370 | "combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)"); |
371 | |
372 | static PyObject * |
373 | itertools_combinations_impl(PyTypeObject *type, PyObject *iterable, |
374 | Py_ssize_t r); |
375 | |
376 | static PyObject * |
377 | itertools_combinations(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
378 | { |
379 | PyObject *return_value = NULL; |
380 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
381 | static _PyArg_Parser _parser = {NULL, _keywords, "combinations", 0}; |
382 | PyObject *argsbuf[2]; |
383 | PyObject * const *fastargs; |
384 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
385 | PyObject *iterable; |
386 | Py_ssize_t r; |
387 | |
388 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); |
389 | if (!fastargs) { Branch (389:9): [True: 3, False: 6.01k]
|
390 | goto exit; |
391 | } |
392 | iterable = fastargs[0]; |
393 | { |
394 | Py_ssize_t ival = -1; |
395 | PyObject *iobj = _PyNumber_Index(fastargs[1]); |
396 | if (iobj != NULL) { Branch (396:13): [True: 6.01k, False: 0]
|
397 | ival = PyLong_AsSsize_t(iobj); |
398 | Py_DECREF(iobj); |
399 | } |
400 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (400:13): [True: 0, False: 6.01k]
Branch (400:27): [True: 0, False: 0]
|
401 | goto exit; |
402 | } |
403 | r = ival; |
404 | } |
405 | return_value = itertools_combinations_impl(type, iterable, r); |
406 | |
407 | exit: |
408 | return return_value; |
409 | } |
410 | |
411 | PyDoc_STRVAR(itertools_combinations_with_replacement__doc__, |
412 | "combinations_with_replacement(iterable, r)\n" |
413 | "--\n" |
414 | "\n" |
415 | "Return successive r-length combinations of elements in the iterable allowing individual elements to have successive repeats.\n" |
416 | "\n" |
417 | "combinations_with_replacement(\'ABC\', 2) --> (\'A\',\'A\'), (\'A\',\'B\'), (\'A\',\'C\'), (\'B\',\'B\'), (\'B\',\'C\'), (\'C\',\'C\')"); |
418 | |
419 | static PyObject * |
420 | itertools_combinations_with_replacement_impl(PyTypeObject *type, |
421 | PyObject *iterable, |
422 | Py_ssize_t r); |
423 | |
424 | static PyObject * |
425 | itertools_combinations_with_replacement(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
426 | { |
427 | PyObject *return_value = NULL; |
428 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
429 | static _PyArg_Parser _parser = {NULL, _keywords, "combinations_with_replacement", 0}; |
430 | PyObject *argsbuf[2]; |
431 | PyObject * const *fastargs; |
432 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
433 | PyObject *iterable; |
434 | Py_ssize_t r; |
435 | |
436 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); |
437 | if (!fastargs) { Branch (437:9): [True: 3, False: 992]
|
438 | goto exit; |
439 | } |
440 | iterable = fastargs[0]; |
441 | { |
442 | Py_ssize_t ival = -1; |
443 | PyObject *iobj = _PyNumber_Index(fastargs[1]); |
444 | if (iobj != NULL) { Branch (444:13): [True: 992, False: 0]
|
445 | ival = PyLong_AsSsize_t(iobj); |
446 | Py_DECREF(iobj); |
447 | } |
448 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (448:13): [True: 0, False: 992]
Branch (448:27): [True: 0, False: 0]
|
449 | goto exit; |
450 | } |
451 | r = ival; |
452 | } |
453 | return_value = itertools_combinations_with_replacement_impl(type, iterable, r); |
454 | |
455 | exit: |
456 | return return_value; |
457 | } |
458 | |
459 | PyDoc_STRVAR(itertools_permutations__doc__, |
460 | "permutations(iterable, r=None)\n" |
461 | "--\n" |
462 | "\n" |
463 | "Return successive r-length permutations of elements in the iterable.\n" |
464 | "\n" |
465 | "permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)"); |
466 | |
467 | static PyObject * |
468 | itertools_permutations_impl(PyTypeObject *type, PyObject *iterable, |
469 | PyObject *robj); |
470 | |
471 | static PyObject * |
472 | itertools_permutations(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
473 | { |
474 | PyObject *return_value = NULL; |
475 | static const char * const _keywords[] = {"iterable", "r", NULL}; |
476 | static _PyArg_Parser _parser = {NULL, _keywords, "permutations", 0}; |
477 | PyObject *argsbuf[2]; |
478 | PyObject * const *fastargs; |
479 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
480 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE5 (kwargs) : 01.31k ) - 1; Branch (480:36): [True: 5, False: 1.31k]
|
481 | PyObject *iterable; |
482 | PyObject *robj = Py_None; |
483 | |
484 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); |
485 | if (!fastargs) { Branch (485:9): [True: 2, False: 1.32k]
|
486 | goto exit; |
487 | } |
488 | iterable = fastargs[0]; |
489 | if (!noptargs) { Branch (489:9): [True: 341, False: 980]
|
490 | goto skip_optional_pos; |
491 | } |
492 | robj = fastargs[1]; |
493 | skip_optional_pos: |
494 | return_value = itertools_permutations_impl(type, iterable, robj); |
495 | |
496 | exit: |
497 | return return_value; |
498 | } |
499 | |
500 | PyDoc_STRVAR(itertools_accumulate__doc__, |
501 | "accumulate(iterable, func=None, *, initial=None)\n" |
502 | "--\n" |
503 | "\n" |
504 | "Return series of accumulated sums (or other binary function results)."); |
505 | |
506 | static PyObject * |
507 | itertools_accumulate_impl(PyTypeObject *type, PyObject *iterable, |
508 | PyObject *binop, PyObject *initial); |
509 | |
510 | static PyObject * |
511 | itertools_accumulate(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
512 | { |
513 | PyObject *return_value = NULL; |
514 | static const char * const _keywords[] = {"iterable", "func", "initial", NULL}; |
515 | static _PyArg_Parser _parser = {NULL, _keywords, "accumulate", 0}; |
516 | PyObject *argsbuf[3]; |
517 | PyObject * const *fastargs; |
518 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
519 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE15 (kwargs) : 0170 ) - 1; Branch (519:36): [True: 15, False: 170]
|
520 | PyObject *iterable; |
521 | PyObject *binop = Py_None; |
522 | PyObject *initial = Py_None; |
523 | |
524 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); |
525 | if (!fastargs) { Branch (525:9): [True: 3, False: 182]
|
526 | goto exit; |
527 | } |
528 | iterable = fastargs[0]; |
529 | if (!noptargs) { Branch (529:9): [True: 102, False: 80]
|
530 | goto skip_optional_pos; |
531 | } |
532 | if (fastargs[1]) { Branch (532:9): [True: 71, False: 9]
|
533 | binop = fastargs[1]; |
534 | if (!--noptargs) { Branch (534:13): [True: 71, False: 0]
|
535 | goto skip_optional_pos; |
536 | } |
537 | } |
538 | skip_optional_pos: |
539 | if (!noptargs) { Branch (539:9): [True: 173, False: 9]
|
540 | goto skip_optional_kwonly; |
541 | } |
542 | initial = fastargs[2]; |
543 | skip_optional_kwonly: |
544 | return_value = itertools_accumulate_impl(type, iterable, binop, initial); |
545 | |
546 | exit: |
547 | return return_value; |
548 | } |
549 | |
550 | PyDoc_STRVAR(itertools_compress__doc__, |
551 | "compress(data, selectors)\n" |
552 | "--\n" |
553 | "\n" |
554 | "Return data elements corresponding to true selector elements.\n" |
555 | "\n" |
556 | "Forms a shorter iterator from selected data elements using the selectors to\n" |
557 | "choose the data elements."); |
558 | |
559 | static PyObject * |
560 | itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2); |
561 | |
562 | static PyObject * |
563 | itertools_compress(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
564 | { |
565 | PyObject *return_value = NULL; |
566 | static const char * const _keywords[] = {"data", "selectors", NULL}; |
567 | static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0}; |
568 | PyObject *argsbuf[2]; |
569 | PyObject * const *fastargs; |
570 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
571 | PyObject *seq1; |
572 | PyObject *seq2; |
573 | |
574 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); |
575 | if (!fastargs) { Branch (575:9): [True: 2, False: 291]
|
576 | goto exit; |
577 | } |
578 | seq1 = fastargs[0]; |
579 | seq2 = fastargs[1]; |
580 | return_value = itertools_compress_impl(type, seq1, seq2); |
581 | |
582 | exit: |
583 | return return_value; |
584 | } |
585 | |
586 | PyDoc_STRVAR(itertools_filterfalse__doc__, |
587 | "filterfalse(function, iterable, /)\n" |
588 | "--\n" |
589 | "\n" |
590 | "Return those items of iterable for which function(item) is false.\n" |
591 | "\n" |
592 | "If function is None, return the items that are false."); |
593 | |
594 | static PyObject * |
595 | itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq); |
596 | |
597 | static PyObject * |
598 | itertools_filterfalse(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
599 | { |
600 | PyObject *return_value = NULL; |
601 | PyObject *func; |
602 | PyObject *seq; |
603 | |
604 | if ((type == &filterfalse_type || Branch (604:10): [True: 357, False: 4]
|
605 | type->tp_init == filterfalse_type.tp_init4 ) && Branch (605:10): [True: 3, False: 1]
|
606 | !360 _PyArg_NoKeywords360 ("filterfalse", kwargs)) { |
607 | goto exit; |
608 | } |
609 | if (!_PyArg_CheckPositional("filterfalse", PyTuple_GET_SIZE(args), 2, 2)) { |
610 | goto exit; |
611 | } |
612 | func = PyTuple_GET_ITEM(args, 0); |
613 | seq = PyTuple_GET_ITEM(args, 1); |
614 | return_value = itertools_filterfalse_impl(type, func, seq); |
615 | |
616 | exit: |
617 | return return_value; |
618 | } |
619 | |
620 | PyDoc_STRVAR(itertools_count__doc__, |
621 | "count(start=0, step=1)\n" |
622 | "--\n" |
623 | "\n" |
624 | "Return a count object whose .__next__() method returns consecutive values.\n" |
625 | "\n" |
626 | "Equivalent to:\n" |
627 | " def count(firstval=0, step=1):\n" |
628 | " x = firstval\n" |
629 | " while 1:\n" |
630 | " yield x\n" |
631 | " x += step"); |
632 | |
633 | static PyObject * |
634 | itertools_count_impl(PyTypeObject *type, PyObject *long_cnt, |
635 | PyObject *long_step); |
636 | |
637 | static PyObject * |
638 | itertools_count(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
639 | { |
640 | PyObject *return_value = NULL; |
641 | static const char * const _keywords[] = {"start", "step", NULL}; |
642 | static _PyArg_Parser _parser = {NULL, _keywords, "count", 0}; |
643 | PyObject *argsbuf[2]; |
644 | PyObject * const *fastargs; |
645 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
646 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE6 (kwargs) : 05.35k ) - 0; Branch (646:36): [True: 6, False: 5.35k]
|
647 | PyObject *long_cnt = NULL; |
648 | PyObject *long_step = NULL; |
649 | |
650 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf); |
651 | if (!fastargs) { Branch (651:9): [True: 1, False: 5.35k]
|
652 | goto exit; |
653 | } |
654 | if (!noptargs) { Branch (654:9): [True: 97, False: 5.26k]
|
655 | goto skip_optional_pos; |
656 | } |
657 | if (fastargs[0]) { Branch (657:9): [True: 5.25k, False: 2]
|
658 | long_cnt = fastargs[0]; |
659 | if (!--noptargs) { Branch (659:13): [True: 3.52k, False: 1.73k]
|
660 | goto skip_optional_pos; |
661 | } |
662 | } |
663 | long_step = fastargs[1]; |
664 | skip_optional_pos: |
665 | return_value = itertools_count_impl(type, long_cnt, long_step); |
666 | |
667 | exit: |
668 | return return_value; |
669 | } |
670 | /*[clinic end generated code: output=659251a811ff89ed input=a9049054013a1b77]*/ |