8000 address review: revert math changes · python/cpython@b3a9a78 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3a9a78

Browse files
committed
address review: revert math changes
1 parent aa2044c commit b3a9a78

File tree

2 files changed

+37
-143
lines changed

2 files changed

+37
-143
lines changed

Modules/clinic/mathmodule.c.h

Lines changed: 1 addition & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/mathmodule.c

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,8 @@ m_log10(double x)
719719
}
720720

721721

722-
/*[clinic input]
723-
math.gcd
724-
725-
*integers as args: object
726-
727-
Greatest Common Divisor.
728-
[clinic start generated code]*/
729-
730722
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)
733724
{
734725
// Fast-path for the common case: gcd(int, int)
735726
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)
772763
return res;
773764
}
774765

766+
PyDoc_STRVAR(math_gcd_doc,
767+
"gcd($module, *integers)\n"
768+
"--\n"
769+
"\n"
770+
"Greatest Common Divisor.");
771+
775772

776773
static PyObject *
777774
long_lcm(PyObject *a, PyObject *b)
@@ -801,17 +798,8 @@ long_lcm(PyObject *a, PyObject *b)
801798
}
802799

803800

804-
/*[clinic input]
805-
math.lcm
806-
807-
*integers as args: object
808-
809-
Least Common Multiple.
810-
[clinic start generated code]*/
811-
812801
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)
815803
{
816804
PyObject *res, *x;
817805
Py_ssize_t i;
@@ -851,6 +839,13 @@ math_lcm_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args)
851839
}
852840

853841

842+
PyDoc_STRVAR(math_lcm_doc,
843+
"lcm($module, *integers)\n"
844+
"--\n"
845+
"\n"
846+
"Least Common Multiple.");
847+
848+
854849
/* Call is_error when errno != 0, and where x is the result libm
855850
* returned. is_error will usually set up an exception and return
856851
* 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)
26262621
return NULL;
26272622
}
26282623

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 */
26482625
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)
26512627
{
26522628
Py_ssize_t i;
26532629
PyObject *item;
@@ -2688,6 +2664,22 @@ math_hypot_impl(PyObject *module, Py_ssize_t nargs, PyObject *const *args)
26882664

26892665
#undef NUM_STACK_ELEMS
26902666

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+
26912683
/** sumprod() ***************************************************************/
26922684

26932685
/* Forward declaration */
@@ -4120,14 +4112,14 @@ static PyMethodDef math_methods[] = {
41204112
MATH_FREXP_METHODDEF
41214113
MATH_FSUM_METHODDEF
41224114
{"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},
41254117
MATH_ISCLOSE_METHODDEF
41264118
MATH_ISFINITE_METHODDEF
41274119
MATH_ISINF_METHODDEF
41284120
MATH_ISNAN_METHODDEF
41294121
MATH_ISQRT_METHODDEF
4130-
MATH_LCM_METHODDEF
4122+
{"lcm", _PyCFunction_CAST(math_lcm), METH_FASTCALL, math_lcm_doc},
41314123
MATH_LDEXP_METHODDEF
41324124
{"lgamma", math_lgamma, METH_O, math_lgamma_doc},
41334125
{"log", _PyCFunction_CAST(math_log), METH_FASTCALL, math_log_doc},

0 commit comments

Comments
 (0)
0