From d2eb71e398e4cc8e794fd7904bd4e186498078ad Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 26 Aug 2018 14:04:00 -0700 Subject: [PATCH 1/2] Add fast path for exact floats. Saves function call overhead and lets inner-loop be performed in registers with no spills/reloads. --- Modules/mathmodule.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 2d483afff54d1b..1082c44860fda5 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2183,9 +2183,13 @@ math_hypot(PyObject *self, PyObject *args) } for (i=0 ; i Date: Sun, 26 Aug 2018 16:27:35 -0700 Subject: [PATCH 2/2] Extend the exact float fastpath to math_dist(). --- Modules/mathmodule.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 1082c44860fda5..62d327998fd183 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2134,14 +2134,22 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q) } for (i=0 ; i