@@ -719,17 +719,8 @@ 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
-
730
722
static PyObject *
731
- math_gcd_impl (PyObject * module , Py_ssize_t nargs , PyObject * const * args )
732
- /*[clinic end generated code: output=b57687fcf431c1b8 input=94e675b7ceeaf0c9]*/
723
+ math_gcd (PyObject * module , PyObject * const * args , Py_ssize_t nargs )
733
724
{
734
725
// Fast-path for the common case: gcd(int, int)
735
726
if (nargs == 2 && PyLong_CheckExact (args [0 ]) && PyLong_CheckExact (args [1 ]))
@@ -772,6 +763,12 @@ math_gcd_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args)
772
763
return res ;
773
764
}
774
765
766
+ PyDoc_STRVAR (math_gcd_doc ,
767
+ "gcd($module, *integers)\n"
768
+ "--\n"
769
+ "\n"
770
+ "Greatest Common Divisor." );
771
+
775
772
776
773
static PyObject *
777
774
long_lcm (PyObject * a , PyObject * b )
@@ -801,17 +798,8 @@ long_lcm(PyObject *a, PyObject *b)
801
798
}
802
799
803
800
804
- /*[clinic input]
805
- math.lcm
806
-
807
- *integers as args: object
808
-
809
- Least Common Multiple.
810
- [clinic start generated code]*/
811
-
812
801
static PyObject *
813
- math_lcm_impl (PyObject * module , Py_ssize_t nargs , PyObject * const * args )
814
- /*[clinic end generated code: output=f3eff0c25e4d7030 input=e64c33e85f4c47c6]*/
802
+ math_lcm (PyObject * module , PyObject * const * args , Py_ssize_t nargs )
815
803
{
816
804
PyObject * res , * x ;
817
805
Py_ssize_t i ;
@@ -851,6 +839,13 @@ math_lcm_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args)
851
839
}
852
840
853
841
842
+ PyDoc_STRVAR (math_lcm_doc ,
843
+ "lcm($module, *integers)\n"
844
+ "--\n"
845
+ "\n"
846
+ "Least Common Multiple." );
847
+
848
+
854
849
/* Call is_error when errno != 0, and where x is the result libm
855
850
* returned. is_error will usually set up an exception and return
856
851
* true (1), but may return false (0) without setting up an exception.
@@ -2626,28 +2621,9 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
2626
2621
return NULL ;
2627
2622
}
2628
2623
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
-
2624
+ /* AC: cannot convert yet, waiting for *args support */
2648
2625
static PyObject *
2649
- math_hypot_impl (PyObject * module , Py_ssize_t nargs , PyObject * const * args )
2650
- /*[clinic end generated code: output=dcb6d4b7a1102ee1 input=5c0061a2d11235ed]*/
2626
+ math_hypot (PyObject * self , PyObject * const * args , Py_ssize_t nargs )
2651
2627
{
2652
2628
Py_ssize_t i ;
2653
2629
PyObject * item ;
@@ -2688,6 +2664,22 @@ math_hypot_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args)
2688
2664
2689
2665
#undef NUM_STACK_ELEMS
2690
2666
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
+
2691
2683
/** sumprod() ***************************************************************/
2692
2684
2693
2685
/* Forward declaration */
@@ -4120,14 +4112,14 @@ static PyMethodDef math_methods[] = {
4120
4112
MATH_FREXP_METHODDEF
4121
4113
MATH_FSUM_METHODDEF
4122
4114
{"gamma" , math_gamma , METH_O , math_gamma_doc },
4123
- MATH_GCD_METHODDEF
4124
- MATH_HYPOT_METHODDEF
4115
+ { "gcd" , _PyCFunction_CAST ( math_gcd ), METH_FASTCALL , math_gcd_doc },
4116
+ { "hypot" , _PyCFunction_CAST ( math_hypot ), METH_FASTCALL , math_hypot_doc },
4125
4117
MATH_ISCLOSE_METHODDEF
4126
4118
MATH_ISFINITE_METHODDEF
4127
4119
MATH_ISINF_METHODDEF
4128
4120
MATH_ISNAN_METHODDEF
4129
4121
MATH_ISQRT_METHODDEF
4130
- MATH_LCM_METHODDEF
4122
+ { "lcm" , _PyCFunction_CAST ( math_lcm ), METH_FASTCALL , math_lcm_doc },
4131
4123
MATH_LDEXP_METHODDEF
4132
4124
{"lgamma" , math_lgamma , METH_O , math_lgamma_doc },
4133
4125
{"log" , _PyCFunction_CAST (math_log ), METH_FASTCALL , math_log_doc },
0 commit comments