diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-07-27 21:26:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-07-27 21:26:58 (GMT) |
commit | 76821bab9cb77fa7f847e66f8b2309ca30546c7f (patch) | |
tree | d7abe932c07b4100e4116aa4d8f840ce2c29a738 /Modules/clinic | |
parent | 171019354aa2c717af2e7b2c90aec7b9724f7282 (diff) | |
download | cpython-76821bab9cb77fa7f847e66f8b2309ca30546c7f.zip cpython-76821bab9cb77fa7f847e66f8b2309ca30546c7f.tar.gz cpython-76821bab9cb77fa7f847e66f8b2309ca30546c7f.tar.bz2 |
bpo-37691: Let math.dist() accept sequences and iterables for coordinates (GH-14975) (GH-14984)
(cherry picked from commit 6b5f1b496f0b20144592b640b9c975df43a29eb0)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/mathmodule.c.h | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index 966b99b..84561b9 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -297,8 +297,8 @@ PyDoc_STRVAR(math_dist__doc__, "\n" "Return the Euclidean distance between two points p and q.\n" "\n" -"The points should be specified as tuples of coordinates.\n" -"Both tuples must be the same size.\n" +"The points should be specified as sequences (or iterables) of\n" +"coordinates. Both inputs must have the same dimension.\n" "\n" "Roughly equivalent to:\n" " sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))"); @@ -319,15 +319,7 @@ math_dist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) if (!_PyArg_CheckPositional("dist", nargs, 2, 2)) { goto exit; } - if (!PyTuple_Check(args[0])) { - _PyArg_BadArgument("dist", 1, "tuple", args[0]); - goto exit; - } p = args[0]; - if (!PyTuple_Check(args[1])) { - _PyArg_BadArgument("dist", 2, "tuple", args[1]); - goto exit; - } q = args[1]; return_value = math_dist_impl(module, p, q); @@ -720,4 +712,4 @@ math_comb(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=0eb1e76a769cdd30 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f93cfe13ab2fdb4e input=a9049054013a1b77]*/ |