Skip to content

Turn assertion into a comment to clarify its purpose.#14131

Merged
mdickinson merged 1 commit into
python:masterfrom
mdickinson:fix/isqrt-python-equivalent
Jun 16, 2019
Merged

Turn assertion into a comment to clarify its purpose.#14131
mdickinson merged 1 commit into
python:masterfrom
mdickinson:fix/isqrt-python-equivalent

Conversation

@mdickinson

Copy link
Copy Markdown
Member

There's an assert in the math.isqrt equivalent Python code (which is in a comment in Modules/mathmodule.c). This trivial PR changes that assert to a comment in order to:

  • better clarify the intent of the original assert (it's a loop invariant)
  • better match the C code (which has no such assertion in it)
  • avoid copy-and-pasted Python code being unnecessarily slow - the checks in the assert could easily dominate the running time

Also adds redundant parentheses for readability.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @mdickinson for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-14132 is a backport of this pull request to the 3.8 branch.

@mdickinson mdickinson deleted the fix/isqrt-python-equivalent branch June 16, 2019 16:55
mdickinson added a commit that referenced this pull request Jun 16, 2019
…14131)

(cherry picked from commit 2dfeaa9)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants