Repository navigation
bpo-36027: Extend three-argument pow to negative second argument #13266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5b2f2bc
Extend three-argument pow to allow the second argument to be negative.
mdickinson 0a45fb8
Remove excessive whitespace.
mdickinson 5f372ad
Tidy up imports.
mdickinson 11dec1e
Remove a redundant test.
mdickinson 12b51aa
Merge remote-tracking branch 'origin/master' into invmod
mdickinson fca728e
Clarify that the negative third argument only applies for int type op…
mdickinson 0d70b1b
Minor test updates: restore the test for 'pow(-1, -2, 3)' in test_bui…
mdickinson 4ea0bf0
Cleaner wording in what's new entry.
mdickinson be89d23
Fix typo in what's new entry
mdickinson 4aaec00
DOC: add example of computing an inverse; use inv_x instead of ix.
mdickinson 345cfcc
Merge remote-tracking branch 'origin/master' into invmod
mdickinson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Clarify that the negative third argument only applies for int type op…
…erands.
- Loading branch information
commit fca728e26b9cf72c29ea694b588517546ad051a1
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1261,14 +1261,15 @@ are always available. They are listed here in alphabetical order. | |
| converted to float and a float result is delivered. For example, ``10**2`` | ||
| returns ``100``, but ``10**-2`` returns ``0.01``. | ||
|
|
||
| If *z* is present, all three of *x*, *y* and *z* must be of integer type | ||
| and *z* must be nonzero. If *z* is present and *y* is negative, *x* must | ||
| be relatively prime to *z*. In that case, ``pow(ix, -y, z)`` is returned, | ||
| where *ix* is an inverse to *x* modulo *z*. | ||
| For :class:`int` operands *x* and *y*, if *z* is present, *z* must also be | ||
| of integer type and *z* must be nonzero. If *z* is present and *y* is | ||
| negative, *x* must be relatively prime to *z*. In that case, ``pow(ix, -y, | ||
| z)`` is returned, where *ix* is an inverse to *x* modulo *z*. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this needs an example for clarity: |
||
|
|
||
| .. versionchanged:: 3.8 | ||
| The three-argument form now allows the second argument to be negative, | ||
| permitting computation of modular inverses. | ||
| For :class:`int` operands, the three-argument form of ``pow`` now allows | ||
| the second argument to be negative, permitting computation of modular | ||
| inverses. | ||
|
|
||
|
|
||
| .. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider changing
ixtoinv_xfor readability.