blob: e677bd896cd8858f2b1e8489ce0afbf3d3c532fd [file] [log] [blame]
Serhiy Storchakac9ea9332017-01-19 18:13:09 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(math_gcd__doc__,
6"gcd($module, x, y, /)\n"
7"--\n"
8"\n"
9"greatest common divisor of x and y");
10
11#define MATH_GCD_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020012 {"gcd", (PyCFunction)(void(*)(void))math_gcd, METH_FASTCALL, math_gcd__doc__},
Serhiy Storchakac9ea9332017-01-19 18:13:09 +020013
14static PyObject *
15math_gcd_impl(PyObject *module, PyObject *a, PyObject *b);
16
17static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020018math_gcd(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Serhiy Storchakac9ea9332017-01-19 18:13:09 +020019{
20 PyObject *return_value = NULL;
21 PyObject *a;
22 PyObject *b;
23
Serhiy Storchaka2a39d252019-01-11 18:01:42 +020024 if (!_PyArg_CheckPositional("gcd", nargs, 2, 2)) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +020025 goto exit;
26 }
Serhiy Storchaka2a39d252019-01-11 18:01:42 +020027 a = args[0];
28 b = args[1];
Serhiy Storchakac9ea9332017-01-19 18:13:09 +020029 return_value = math_gcd_impl(module, a, b);
30
31exit:
32 return return_value;
33}
34
35PyDoc_STRVAR(math_ceil__doc__,
36"ceil($module, x, /)\n"
37"--\n"
38"\n"
39"Return the ceiling of x as an Integral.\n"
40"\n"
41"This is the smallest integer >= x.");
42
43#define MATH_CEIL_METHODDEF \
44 {"ceil", (PyCFunction)math_ceil, METH_O, math_ceil__doc__},
45
46PyDoc_STRVAR(math_floor__doc__,
47"floor($module, x, /)\n"
48"--\n"
49"\n"
50"Return the floor of x as an Integral.\n"
51"\n"
52"This is the largest integer <= x.");
53
54#define MATH_FLOOR_METHODDEF \
55 {"floor", (PyCFunction)math_floor, METH_O, math_floor__doc__},
56
57PyDoc_STRVAR(math_fsum__doc__,
58"fsum($module, seq, /)\n"
59"--\n"
60"\n"
61"Return an accurate floating point sum of values in the iterable seq.\n"
62"\n"
63"Assumes IEEE-754 floating point arithmetic.");
64
65#define MATH_FSUM_METHODDEF \
66 {"fsum", (PyCFunction)math_fsum, METH_O, math_fsum__doc__},
67
Mark Dickinson73934b92019-05-18 12:29:50 +010068PyDoc_STRVAR(math_isqrt__doc__,
69"isqrt($module, n, /)\n"
70"--\n"
71"\n"
72"Return the integer part of the square root of the input.");
73
74#define MATH_ISQRT_METHODDEF \
75 {"isqrt", (PyCFunction)math_isqrt, METH_O, math_isqrt__doc__},
76
Serhiy Storchakac9ea9332017-01-19 18:13:09 +020077PyDoc_STRVAR(math_factorial__doc__,
78"factorial($module, x, /)\n"
79"--\n"
80"\n"
81"Find x!.\n"
82"\n"
83"Raise a ValueError if x is negative or non-integral.");
84
85#define MATH_FACTORIAL_METHODDEF \
86 {"factorial", (PyCFunction)math_factorial, METH_O, math_factorial__doc__},
87
88PyDoc_STRVAR(math_trunc__doc__,
89"trunc($module, x, /)\n"
90"--\n"
91"\n"
92"Truncates the Real x to the nearest Integral toward 0.\n"
93"\n"
94"Uses the __trunc__ magic method.");
95
96#define MATH_TRUNC_METHODDEF \
97 {"trunc", (PyCFunction)math_trunc, METH_O, math_trunc__doc__},
98
99PyDoc_STRVAR(math_frexp__doc__,
100"frexp($module, x, /)\n"
101"--\n"
102"\n"
103"Return the mantissa and exponent of x, as pair (m, e).\n"
104"\n"
105"m is a float and e is an int, such that x = m * 2.**e.\n"
106"If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.");
107
108#define MATH_FREXP_METHODDEF \
109 {"frexp", (PyCFunction)math_frexp, METH_O, math_frexp__doc__},
110
111static PyObject *
112math_frexp_impl(PyObject *module, double x);
113
114static PyObject *
115math_frexp(PyObject *module, PyObject *arg)
116{
117 PyObject *return_value = NULL;
118 double x;
119
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200120 x = PyFloat_AsDouble(arg);
121 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200122 goto exit;
123 }
124 return_value = math_frexp_impl(module, x);
125
126exit:
127 return return_value;
128}
129
130PyDoc_STRVAR(math_ldexp__doc__,
131"ldexp($module, x, i, /)\n"
132"--\n"
133"\n"
134"Return x * (2**i).\n"
135"\n"
136"This is essentially the inverse of frexp().");
137
138#define MATH_LDEXP_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200139 {"ldexp", (PyCFunction)(void(*)(void))math_ldexp, METH_FASTCALL, math_ldexp__doc__},
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200140
141static PyObject *
142math_ldexp_impl(PyObject *module, double x, PyObject *i);
143
144static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200145math_ldexp(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200146{
147 PyObject *return_value = NULL;
148 double x;
149 PyObject *i;
150
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200151 if (!_PyArg_CheckPositional("ldexp", nargs, 2, 2)) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200152 goto exit;
153 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200154 x = PyFloat_AsDouble(args[0]);
155 if (PyErr_Occurred()) {
156 goto exit;
157 }
158 i = args[1];
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200159 return_value = math_ldexp_impl(module, x, i);
160
161exit:
162 return return_value;
163}
164
165PyDoc_STRVAR(math_modf__doc__,
166"modf($module, x, /)\n"
167"--\n"
168"\n"
169"Return the fractional and integer parts of x.\n"
170"\n"
171"Both results carry the sign of x and are floats.");
172
173#define MATH_MODF_METHODDEF \
174 {"modf", (PyCFunction)math_modf, METH_O, math_modf__doc__},
175
176static PyObject *
177math_modf_impl(PyObject *module, double x);
178
179static PyObject *
180math_modf(PyObject *module, PyObject *arg)
181{
182 PyObject *return_value = NULL;
183 double x;
184
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200185 x = PyFloat_AsDouble(arg);
186 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200187 goto exit;
188 }
189 return_value = math_modf_impl(module, x);
190
191exit:
192 return return_value;
193}
194
195PyDoc_STRVAR(math_log__doc__,
196"log(x, [base=math.e])\n"
197"Return the logarithm of x to the given base.\n"
198"\n"
199"If the base not specified, returns the natural logarithm (base e) of x.");
200
201#define MATH_LOG_METHODDEF \
202 {"log", (PyCFunction)math_log, METH_VARARGS, math_log__doc__},
203
204static PyObject *
205math_log_impl(PyObject *module, PyObject *x, int group_right_1,
206 PyObject *base);
207
208static PyObject *
209math_log(PyObject *module, PyObject *args)
210{
211 PyObject *return_value = NULL;
212 PyObject *x;
213 int group_right_1 = 0;
214 PyObject *base = NULL;
215
216 switch (PyTuple_GET_SIZE(args)) {
217 case 1:
218 if (!PyArg_ParseTuple(args, "O:log", &x)) {
219 goto exit;
220 }
221 break;
222 case 2:
223 if (!PyArg_ParseTuple(args, "OO:log", &x, &base)) {
224 goto exit;
225 }
226 group_right_1 = 1;
227 break;
228 default:
229 PyErr_SetString(PyExc_TypeError, "math.log requires 1 to 2 arguments");
230 goto exit;
231 }
232 return_value = math_log_impl(module, x, group_right_1, base);
233
234exit:
235 return return_value;
236}
237
238PyDoc_STRVAR(math_log2__doc__,
239"log2($module, x, /)\n"
240"--\n"
241"\n"
242"Return the base 2 logarithm of x.");
243
244#define MATH_LOG2_METHODDEF \
245 {"log2", (PyCFunction)math_log2, METH_O, math_log2__doc__},
246
247PyDoc_STRVAR(math_log10__doc__,
248"log10($module, x, /)\n"
249"--\n"
250"\n"
251"Return the base 10 logarithm of x.");
252
253#define MATH_LOG10_METHODDEF \
254 {"log10", (PyCFunction)math_log10, METH_O, math_log10__doc__},
255
256PyDoc_STRVAR(math_fmod__doc__,
257"fmod($module, x, y, /)\n"
258"--\n"
259"\n"
260"Return fmod(x, y), according to platform C.\n"
261"\n"
262"x % y may differ.");
263
264#define MATH_FMOD_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200265 {"fmod", (PyCFunction)(void(*)(void))math_fmod, METH_FASTCALL, math_fmod__doc__},
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200266
267static PyObject *
268math_fmod_impl(PyObject *module, double x, double y);
269
270static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200271math_fmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200272{
273 PyObject *return_value = NULL;
274 double x;
275 double y;
276
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200277 if (!_PyArg_CheckPositional("fmod", nargs, 2, 2)) {
278 goto exit;
279 }
280 x = PyFloat_AsDouble(args[0]);
281 if (PyErr_Occurred()) {
282 goto exit;
283 }
284 y = PyFloat_AsDouble(args[1]);
285 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200286 goto exit;
287 }
288 return_value = math_fmod_impl(module, x, y);
289
290exit:
291 return return_value;
292}
293
Raymond Hettinger9c18b1a2018-07-31 00:45:49 -0700294PyDoc_STRVAR(math_dist__doc__,
295"dist($module, p, q, /)\n"
296"--\n"
297"\n"
298"Return the Euclidean distance between two points p and q.\n"
299"\n"
300"The points should be specified as tuples of coordinates.\n"
301"Both tuples must be the same size.\n"
302"\n"
303"Roughly equivalent to:\n"
304" sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))");
305
306#define MATH_DIST_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200307 {"dist", (PyCFunction)(void(*)(void))math_dist, METH_FASTCALL, math_dist__doc__},
Raymond Hettinger9c18b1a2018-07-31 00:45:49 -0700308
309static PyObject *
310math_dist_impl(PyObject *module, PyObject *p, PyObject *q);
311
312static PyObject *
313math_dist(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
314{
315 PyObject *return_value = NULL;
316 PyObject *p;
317 PyObject *q;
318
Serhiy Storchaka2a39d252019-01-11 18:01:42 +0200319 if (!_PyArg_CheckPositional("dist", nargs, 2, 2)) {
Raymond Hettinger9c18b1a2018-07-31 00:45:49 -0700320 goto exit;
321 }
Ammar Askarcb08a712019-01-12 01:23:41 -0500322 if (!PyTuple_Check(args[0])) {
323 _PyArg_BadArgument("dist", 1, "tuple", args[0]);
324 goto exit;
325 }
Serhiy Storchaka2a39d252019-01-11 18:01:42 +0200326 p = args[0];
Ammar Askarcb08a712019-01-12 01:23:41 -0500327 if (!PyTuple_Check(args[1])) {
328 _PyArg_BadArgument("dist", 2, "tuple", args[1]);
329 goto exit;
330 }
Serhiy Storchaka2a39d252019-01-11 18:01:42 +0200331 q = args[1];
Raymond Hettinger9c18b1a2018-07-31 00:45:49 -0700332 return_value = math_dist_impl(module, p, q);
333
334exit:
335 return return_value;
336}
337
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200338PyDoc_STRVAR(math_pow__doc__,
339"pow($module, x, y, /)\n"
340"--\n"
341"\n"
342"Return x**y (x to the power of y).");
343
344#define MATH_POW_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200345 {"pow", (PyCFunction)(void(*)(void))math_pow, METH_FASTCALL, math_pow__doc__},
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200346
347static PyObject *
348math_pow_impl(PyObject *module, double x, double y);
349
350static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200351math_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200352{
353 PyObject *return_value = NULL;
354 double x;
355 double y;
356
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200357 if (!_PyArg_CheckPositional("pow", nargs, 2, 2)) {
358 goto exit;
359 }
360 x = PyFloat_AsDouble(args[0]);
361 if (PyErr_Occurred()) {
362 goto exit;
363 }
364 y = PyFloat_AsDouble(args[1]);
365 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200366 goto exit;
367 }
368 return_value = math_pow_impl(module, x, y);
369
370exit:
371 return return_value;
372}
373
374PyDoc_STRVAR(math_degrees__doc__,
375"degrees($module, x, /)\n"
376"--\n"
377"\n"
378"Convert angle x from radians to degrees.");
379
380#define MATH_DEGREES_METHODDEF \
381 {"degrees", (PyCFunction)math_degrees, METH_O, math_degrees__doc__},
382
383static PyObject *
384math_degrees_impl(PyObject *module, double x);
385
386static PyObject *
387math_degrees(PyObject *module, PyObject *arg)
388{
389 PyObject *return_value = NULL;
390 double x;
391
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200392 x = PyFloat_AsDouble(arg);
393 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200394 goto exit;
395 }
396 return_value = math_degrees_impl(module, x);
397
398exit:
399 return return_value;
400}
401
402PyDoc_STRVAR(math_radians__doc__,
403"radians($module, x, /)\n"
404"--\n"
405"\n"
406"Convert angle x from degrees to radians.");
407
408#define MATH_RADIANS_METHODDEF \
409 {"radians", (PyCFunction)math_radians, METH_O, math_radians__doc__},
410
411static PyObject *
412math_radians_impl(PyObject *module, double x);
413
414static PyObject *
415math_radians(PyObject *module, PyObject *arg)
416{
417 PyObject *return_value = NULL;
418 double x;
419
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200420 x = PyFloat_AsDouble(arg);
421 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200422 goto exit;
423 }
424 return_value = math_radians_impl(module, x);
425
426exit:
427 return return_value;
428}
429
430PyDoc_STRVAR(math_isfinite__doc__,
431"isfinite($module, x, /)\n"
432"--\n"
433"\n"
434"Return True if x is neither an infinity nor a NaN, and False otherwise.");
435
436#define MATH_ISFINITE_METHODDEF \
437 {"isfinite", (PyCFunction)math_isfinite, METH_O, math_isfinite__doc__},
438
439static PyObject *
440math_isfinite_impl(PyObject *module, double x);
441
442static PyObject *
443math_isfinite(PyObject *module, PyObject *arg)
444{
445 PyObject *return_value = NULL;
446 double x;
447
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200448 x = PyFloat_AsDouble(arg);
449 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200450 goto exit;
451 }
452 return_value = math_isfinite_impl(module, x);
453
454exit:
455 return return_value;
456}
457
458PyDoc_STRVAR(math_isnan__doc__,
459"isnan($module, x, /)\n"
460"--\n"
461"\n"
462"Return True if x is a NaN (not a number), and False otherwise.");
463
464#define MATH_ISNAN_METHODDEF \
465 {"isnan", (PyCFunction)math_isnan, METH_O, math_isnan__doc__},
466
467static PyObject *
468math_isnan_impl(PyObject *module, double x);
469
470static PyObject *
471math_isnan(PyObject *module, PyObject *arg)
472{
473 PyObject *return_value = NULL;
474 double x;
475
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200476 x = PyFloat_AsDouble(arg);
477 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200478 goto exit;
479 }
480 return_value = math_isnan_impl(module, x);
481
482exit:
483 return return_value;
484}
485
486PyDoc_STRVAR(math_isinf__doc__,
487"isinf($module, x, /)\n"
488"--\n"
489"\n"
490"Return True if x is a positive or negative infinity, and False otherwise.");
491
492#define MATH_ISINF_METHODDEF \
493 {"isinf", (PyCFunction)math_isinf, METH_O, math_isinf__doc__},
494
495static PyObject *
496math_isinf_impl(PyObject *module, double x);
497
498static PyObject *
499math_isinf(PyObject *module, PyObject *arg)
500{
501 PyObject *return_value = NULL;
502 double x;
503
Serhiy Storchaka32d96a22018-12-25 13:23:47 +0200504 x = PyFloat_AsDouble(arg);
505 if (PyErr_Occurred()) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200506 goto exit;
507 }
508 return_value = math_isinf_impl(module, x);
509
510exit:
511 return return_value;
512}
513
514PyDoc_STRVAR(math_isclose__doc__,
515"isclose($module, /, a, b, *, rel_tol=1e-09, abs_tol=0.0)\n"
516"--\n"
517"\n"
518"Determine whether two floating point numbers are close in value.\n"
519"\n"
520" rel_tol\n"
521" maximum difference for being considered \"close\", relative to the\n"
522" magnitude of the input values\n"
523" abs_tol\n"
524" maximum difference for being considered \"close\", regardless of the\n"
525" magnitude of the input values\n"
526"\n"
527"Return True if a is close in value to b, and False otherwise.\n"
528"\n"
529"For the values to be considered close, the difference between them\n"
530"must be smaller than at least one of the tolerances.\n"
531"\n"
532"-inf, inf and NaN behave similarly to the IEEE 754 Standard. That\n"
533"is, NaN is not close to anything, even itself. inf and -inf are\n"
534"only close to themselves.");
535
536#define MATH_ISCLOSE_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200537 {"isclose", (PyCFunction)(void(*)(void))math_isclose, METH_FASTCALL|METH_KEYWORDS, math_isclose__doc__},
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200538
539static int
540math_isclose_impl(PyObject *module, double a, double b, double rel_tol,
541 double abs_tol);
542
543static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200544math_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200545{
546 PyObject *return_value = NULL;
547 static const char * const _keywords[] = {"a", "b", "rel_tol", "abs_tol", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +0200548 static _PyArg_Parser _parser = {NULL, _keywords, "isclose", 0};
549 PyObject *argsbuf[4];
550 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200551 double a;
552 double b;
553 double rel_tol = 1e-09;
554 double abs_tol = 0.0;
555 int _return_value;
556
Serhiy Storchaka31913912019-03-14 10:32:22 +0200557 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
558 if (!args) {
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200559 goto exit;
560 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200561 a = PyFloat_AsDouble(args[0]);
562 if (PyErr_Occurred()) {
563 goto exit;
564 }
565 b = PyFloat_AsDouble(args[1]);
566 if (PyErr_Occurred()) {
567 goto exit;
568 }
569 if (!noptargs) {
570 goto skip_optional_kwonly;
571 }
572 if (args[2]) {
573 rel_tol = PyFloat_AsDouble(args[2]);
574 if (PyErr_Occurred()) {
575 goto exit;
576 }
577 if (!--noptargs) {
578 goto skip_optional_kwonly;
579 }
580 }
581 abs_tol = PyFloat_AsDouble(args[3]);
582 if (PyErr_Occurred()) {
583 goto exit;
584 }
585skip_optional_kwonly:
Serhiy Storchakac9ea9332017-01-19 18:13:09 +0200586 _return_value = math_isclose_impl(module, a, b, rel_tol, abs_tol);
587 if ((_return_value == -1) && PyErr_Occurred()) {
588 goto exit;
589 }
590 return_value = PyBool_FromLong((long)_return_value);
591
592exit:
593 return return_value;
594}
Pablo Galindobc098512019-02-07 07:04:02 +0000595
596PyDoc_STRVAR(math_prod__doc__,
597"prod($module, iterable, /, *, start=1)\n"
598"--\n"
599"\n"
600"Calculate the product of all the elements in the input iterable.\n"
601"\n"
602"The default start value for the product is 1.\n"
603"\n"
604"When the iterable is empty, return the start value. This function is\n"
605"intended specifically for use with numeric values and may reject\n"
606"non-numeric types.");
607
608#define MATH_PROD_METHODDEF \
609 {"prod", (PyCFunction)(void(*)(void))math_prod, METH_FASTCALL|METH_KEYWORDS, math_prod__doc__},
610
611static PyObject *
612math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start);
613
614static PyObject *
615math_prod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
616{
617 PyObject *return_value = NULL;
618 static const char * const _keywords[] = {"", "start", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +0200619 static _PyArg_Parser _parser = {NULL, _keywords, "prod", 0};
620 PyObject *argsbuf[2];
621 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
Pablo Galindobc098512019-02-07 07:04:02 +0000622 PyObject *iterable;
623 PyObject *start = NULL;
624
Serhiy Storchaka31913912019-03-14 10:32:22 +0200625 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
626 if (!args) {
Pablo Galindobc098512019-02-07 07:04:02 +0000627 goto exit;
628 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200629 iterable = args[0];
630 if (!noptargs) {
631 goto skip_optional_kwonly;
632 }
633 start = args[1];
634skip_optional_kwonly:
Pablo Galindobc098512019-02-07 07:04:02 +0000635 return_value = math_prod_impl(module, iterable, start);
636
637exit:
638 return return_value;
639}
Mark Dickinson73934b92019-05-18 12:29:50 +0100640/*[clinic end generated code: output=aeed62f403b90199 input=a9049054013a1b77]*/