summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-16 10:14:02 -0700
committerMark Dickinson <dickinsm@gmail.com>2019-06-16 18:14:02 +0100
commit3f3efed3315f06ca3412bc8f4506e994ab84a8b3 (patch)
tree0021888d5c2a7e5c13ba7748dcb3f6b793ddefcc /Modules
parent599f7ecb70f1b9714c702322b235b4d8155205ae (diff)
downloadcpython-git-3f3efed3315f06ca3412bc8f4506e994ab84a8b3.tar.gz
Turn math.isqrt assertion into a comment to clarify its purpose. (GH-14131)
(cherry picked from commit 2dfeaa9222e2ed6b6e32faaf08e5b0f77318f0a7) Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mathmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 76d821c65b..82a9a14724 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)