Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2dfeaa9

Browse files
authored
Turn math.isqrt assertion into a comment to clarify its purpose. (GH-14131)
1 parent 45e0411 commit 2dfeaa9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/mathmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,10 @@ Here's Python code equivalent to the C implementation below:
15271527
a = 1
15281528
d = 0
15291529
for s in reversed(range(c.bit_length())):
1530+
# Loop invariant: (a-1)**2 < (n >> 2*(c - d)) < (a+1)**2
15301531
e = d
15311532
d = c >> s
15321533
a = (a << d - e - 1) + (n >> 2*c - e - d + 1) // a
1533-
assert (a-1)**2 < n >> 2*(c - d) < (a+1)**2
15341534
15351535
return a - (a*a > n)
15361536

0 commit comments

Comments
 (0)