summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2019-06-16 16:53:21 (GMT)
committerGitHub <noreply@github.com>2019-06-16 16:53:21 (GMT)
commit2dfeaa9222e2ed6b6e32faaf08e5b0f77318f0a7 (patch)
tree7723b86140512630c0f7fe8ff126e41b1aae81c3 /Modules/mathmodule.c
parent45e0411eee023b21acf1615e995d26058d66c0f1 (diff)
downloadcpython-2dfeaa9222e2ed6b6e32faaf08e5b0f77318f0a7.zip
cpython-2dfeaa9222e2ed6b6e32faaf08e5b0f77318f0a7.tar.gz
cpython-2dfeaa9222e2ed6b6e32faaf08e5b0f77318f0a7.tar.bz2
Turn math.isqrt assertion into a comment to clarify its purpose. (GH-14131)
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r--Modules/mathmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 76d821c..82a9a14 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)