| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -719,8 +719,17 @@ m_log10(double x) | |||
| 719 | 719 | } | |
| 720 | 720 | ||
| 721 | 721 | ||
| 722 | + /*[clinic input] | ||
| 723 | + math.gcd | ||
| 724 | + | ||
| 725 | + *integers as args: object | ||
| 726 | + | ||
| 727 | + Greatest Common Divisor. | ||
| 728 | + [clinic start generated code]*/ | ||
| 729 | + | ||
| 722 | 730 | static PyObject * | |
| 723 | - math_gcd(PyObject *module, PyObject * const *args, Py_ssize_t nargs) | ||
| 731 | + math_gcd_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args) | ||
| 732 | + /*[clinic end generated code: output=b57687fcf431c1b8 input=94e675b7ceeaf0c9]*/ | ||
| 724 | 733 | { | |
| 725 | 734 | // Fast-path for the common case: gcd(int, int) | |
| 726 | 735 | if (nargs == 2 && PyLong_CheckExact(args[0]) && PyLong_CheckExact(args[1])) | |
@@ -763,12 +772,6 @@ math_gcd(PyObject *module, PyObject * const *args, Py_ssize_t nargs) | |||
| 763 | 772 | return res; | |
| 764 | 773 | } | |
| 765 | 774 | ||
| 766 | - PyDoc_STRVAR(math_gcd_doc, | ||
| 767 | - "gcd($module, *integers)\n" | ||
| 768 | - "--\n" | ||
| 769 | - "\n" | ||
| 770 | - "Greatest Common Divisor."); | ||
| 771 | - | ||
| 772 | 775 | ||
| 773 | 776 | static PyObject * | |
| 774 | 777 | long_lcm(PyObject *a, PyObject *b) | |
@@ -798,8 +801,17 @@ long_lcm(PyObject *a, PyObject *b) | |||
| 798 | 801 | } | |
| 799 | 802 | ||
| 800 | 803 | ||
| 804 | + /*[clinic input] | ||
| 805 | + math.lcm | ||
| 806 | + | ||
| 807 | + *integers as args: object | ||
| 808 | + | ||
| 809 | + Least Common Multiple. | ||
| 810 | + [clinic start generated code]*/ | ||
| 811 | + | ||
| 801 | 812 | static PyObject * | |
| 802 | - math_lcm(PyObject *module, PyObject * const *args, Py_ssize_t nargs) | ||
| 813 | + math_lcm_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args) | ||
| 814 | + /*[clinic end generated code: output=f3eff0c25e4d7030 input=e64c33e85f4c47c6]*/ | ||
| 803 | 815 | { | |
| 804 | 816 | PyObject *res, *x; | |
| 805 | 817 | Py_ssize_t i; | |
@@ -839,13 +851,6 @@ math_lcm(PyObject *module, PyObject * const *args, Py_ssize_t nargs) | |||
| 839 | 851 | } | |
| 840 | 852 | ||
| 841 | 853 | ||
| 842 | - PyDoc_STRVAR(math_lcm_doc, | ||
| 843 | - "lcm($module, *integers)\n" | ||
| 844 | - "--\n" | ||
| 845 | - "\n" | ||
| 846 | - "Least Common Multiple."); | ||
| 847 | - | ||
| 848 | - | ||
| 849 | 854 | /* Call is_error when errno != 0, and where x is the result libm | |
| 850 | 855 | * returned. is_error will usually set up an exception and return | |
| 851 | 856 | * true (1), but may return false (0) without setting up an exception. | |
@@ -2621,9 +2626,28 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q) | |||
| 2621 | 2626 | return NULL; | |
| 2622 | 2627 | } | |
| 2623 | 2628 | ||
| 2624 | - /* AC: cannot convert yet, waiting for *args support */ | ||
| 2629 | + /*[clinic input] | ||
| 2630 | + math.hypot | ||
| 2631 | + | ||
| 2632 | + *coordinates as args: object | ||
| 2633 | + | ||
| 2634 | + Multidimensional Euclidean distance from the origin to a point. | ||
| 2635 | + | ||
| 2636 | + Roughly equivalent to: | ||
| 2637 | + sqrt(sum(x**2 for x in coordinates)) | ||
| 2638 | + | ||
| 2639 | + For a two dimensional point (x, y), gives the hypotenuse | ||
| 2640 | + using the Pythagorean theorem: sqrt(x*x + y*y). | ||
| 2641 | + | ||
| 2642 | + For example, the hypotenuse of a 3/4/5 right triangle is: | ||
| 2643 | + | ||
| 2644 | + >>> hypot(3.0, 4.0) | ||
| 2645 | + 5.0 | ||
| 2646 | + [clinic start generated code]*/ | ||
| 2647 | + | ||
| 2625 | 2648 | static PyObject * | |
| 2626 | - math_hypot(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | ||
| 2649 | + math_hypot_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args) | ||
| 2650 | + /*[clinic end generated code: output=dcb6d4b7a1102ee1 input=5c0061a2d11235ed]*/ | ||
| 2627 | 2651 | { | |
| 2628 | 2652 | Py_ssize_t i; | |
| 2629 | 2653 | PyObject *item; | |
@@ -2664,22 +2688,6 @@ math_hypot(PyObject *self, PyObject *const *args, Py_ssize_t nargs) | |||
| 2664 | 2688 | ||
| 2665 | 2689 | #undef NUM_STACK_ELEMS | |
| 2666 | 2690 | ||
| 2667 | - PyDoc_STRVAR(math_hypot_doc, | ||
| 2668 | - "hypot(*coordinates) -> value\n\n\ | ||
| 2669 | - Multidimensional Euclidean distance from the origin to a point.\n\ | ||
| 2670 | - \n\ | ||
| 2671 | - Roughly equivalent to:\n\ | ||
| 2672 | - sqrt(sum(x**2 for x in coordinates))\n\ | ||
| 2673 | - \n\ | ||
| 2674 | - For a two dimensional point (x, y), gives the hypotenuse\n\ | ||
| 2675 | - using the Pythagorean theorem: sqrt(x*x + y*y).\n\ | ||
| 2676 | - \n\ | ||
| 2677 | - For example, the hypotenuse of a 3/4/5 right triangle is:\n\ | ||
| 2678 | - \n\ | ||
| 2679 | - >>> hypot(3.0, 4.0)\n\ | ||
| 2680 | - 5.0\n\ | ||
| 2681 | - "); | ||
| 2682 | - | ||
| 2683 | 2691 | /** sumprod() ***************************************************************/ | |
| 2684 | 2692 | ||
| 2685 | 2693 | /* Forward declaration */ | |
@@ -4112,14 +4120,14 @@ static PyMethodDef math_methods[] = { | |||
| 4112 | 4120 | MATH_FREXP_METHODDEF | |
| 4113 | 4121 | MATH_FSUM_METHODDEF | |
| 4114 | 4122 | {"gamma", math_gamma, METH_O, math_gamma_doc}, | |
| 4115 | - {"gcd", _PyCFunction_CAST(math_gcd), METH_FASTCALL, math_gcd_doc}, | ||
| 4116 | - {"hypot", _PyCFunction_CAST(math_hypot), METH_FASTCALL, math_hypot_doc}, | ||
| 4123 | + MATH_GCD_METHODDEF | ||
| 4124 | + MATH_HYPOT_METHODDEF | ||
| 4117 | 4125 | MATH_ISCLOSE_METHODDEF | |
| 4118 | 4126 | MATH_ISFINITE_METHODDEF | |
| 4119 | 4127 | MATH_ISINF_METHODDEF | |
| 4120 | 4128 | MATH_ISNAN_METHODDEF | |
| 4121 | 4129 | MATH_ISQRT_METHODDEF | |
| 4122 | - {"lcm", _PyCFunction_CAST(math_lcm), METH_FASTCALL, math_lcm_doc}, | ||
| 4130 | + MATH_LCM_METHODDEF | ||
| 4123 | 4131 | MATH_LDEXP_METHODDEF | |
| 4124 | 4132 | {"lgamma", math_lgamma, METH_O, math_lgamma_doc}, | |
| 4125 | 4133 | {"log", _PyCFunction_CAST(math_log), METH_FASTCALL, math_log_doc}, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments