diff options
author | Ammar Askar <ammar_askar@hotmail.com> | 2019-01-12 06:23:41 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-01-12 06:23:41 (GMT) |
commit | cb08a71c5c534f33d9486677534dafb087c30e8c (patch) | |
tree | 19b46ba5dda5c870c2a2f8614e19e3831e5f3ec8 /Modules/mathmodule.c | |
parent | fdf282d609fd172d52b59a6f1f062eb701494528 (diff) | |
download | cpython-cb08a71c5c534f33d9486677534dafb087c30e8c.zip cpython-cb08a71c5c534f33d9486677534dafb087c30e8c.tar.gz cpython-cb08a71c5c534f33d9486677534dafb087c30e8c.tar.bz2 |
bpo-34838: Use subclass_of for math.dist. (GH-9659)
Argument clinic now generates fast inline code for
positional parsing, so the manually implemented type
check in math.dist can be removed.
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r-- | Modules/mathmodule.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index d56c91c..2db2b45 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2101,8 +2101,8 @@ vector_norm(Py_ssize_t n, double *vec, double max, int found_nan) /*[clinic input] math.dist - p: object - q: object + p: object(subclass_of='&PyTuple_Type') + q: object(subclass_of='&PyTuple_Type') / Return the Euclidean distance between two points p and q. @@ -2116,7 +2116,7 @@ Roughly equivalent to: static PyObject * math_dist_impl(PyObject *module, PyObject *p, PyObject *q) -/*[clinic end generated code: output=56bd9538d06bbcfe input=8c83c07c7a524664]*/ +/*[clinic end generated code: output=56bd9538d06bbcfe input=937122eaa5f19272]*/ { PyObject *item; double max = 0.0; @@ -2126,11 +2126,6 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q) double diffs_on_stack[NUM_STACK_ELEMS]; double *diffs = diffs_on_stack; - if (!PyTuple_Check(p) || !PyTuple_Check(q)) { - PyErr_SetString(PyExc_TypeError, "dist argument must be a tuple"); - return NULL; - } - m = PyTuple_GET_SIZE(p); n = PyTuple_GET_SIZE(q); if (m != n) { |