From 4bb0792cf5b4985410efebc1887c80c29f69cab6 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 16 Jun 2019 17:06:59 +0100 Subject: [PATCH] Turn (slow) assertion into a comment to clarify its purpose. --- Modules/mathmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 76d821c65b4c8b..82a9a14724f5e1 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1527,10 +1527,10 @@ Here's Python code equivalent to the C implementation below: a = 1 d = 0 for s in reversed(range(c.bit_length())): + # Loop invariant: (a-1)**2 < (n >> 2*(c - d)) < (a+1)**2 e = d d = c >> s a = (a << d - e - 1) + (n >> 2*c - e - d + 1) // a - assert (a-1)**2 < n >> 2*(c - d) < (a+1)**2 return a - (a*a > n)