classification
Title: One argument form of math.perm()
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, rhettinger, serhiy.storchaka, tim.peters
Priority: normal Keywords: patch

Created on 2019-06-06 16:30 by rhettinger, last changed 2019-06-08 23:55 by rhettinger. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13905 merged rhettinger, 2019-06-08 00:20
PR 13919 merged miss-islington, 2019-06-08 15:59
Messages (7)
msg344833 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-06 16:30
The perm() function should have a one argument form and change its signature to ``perm(n, k=None)``.  This matches what itertools:

itertools.permutations(iterable, r=None)
   Return successive r length permutations of elements
   in the iterable.

   If r is not specified or is None, then r defaults to
   the length of the iterable and all possible full-length
   permutations are generated.
msg344835 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-06 16:36
perm(n, n) = factorial(n)
msg344837 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2019-06-06 16:41
I agree: perm(n) should return factorial(n).
msg344840 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-06 17:02
I never seen a one argument form of P(n, k) in mathematics. itertools.permutations() corresponds two functions: math.perm() and math .factorial(). Unless you a going to add a new function in the itertools module equal to a one argument form of itertools.permutations() there will be no full symmetry.
msg345020 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-08 03:21
It's possible the word permutations means something different to you than it does to me.  The itertools.permutations() function is only one function, one that includes the default option to generate all permutations.  It does the same as permute(n, r) and permute(n) in Maple; and the same as Permutations[list, n] and Permutations[list] in Mathematica.  For the math module, perm(n) is just a common special case that means all possible arrangements.
msg345053 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-08 15:58
New changeset e119b3d136bd94d880bce4b382096f6de3f38062 by Raymond Hettinger in branch 'master':
bpo-37178: Allow a one argument form of math.perm() (GH-13905)
https://github.com/python/cpython/commit/e119b3d136bd94d880bce4b382096f6de3f38062
msg345054 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-08 16:17
New changeset feaceaafe816e95c4aff15eab0bea6dc2bbfe4fd by Raymond Hettinger (Miss Islington (bot)) in branch '3.8':
bpo-37178: Allow a one argument form of math.perm() (GH-13905) (GH-13919)
https://github.com/python/cpython/commit/feaceaafe816e95c4aff15eab0bea6dc2bbfe4fd
History
Date User Action Args
2019-06-08 23:55:34rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-08 16:17:37rhettingersetmessages: + msg345054
2019-06-08 15:59:30miss-islingtonsetpull_requests: + pull_request13792
2019-06-08 15:58:15rhettingersetmessages: + msg345053
2019-06-08 03:21:17rhettingersetmessages: + msg345020
2019-06-08 00:20:08rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request13778
2019-06-06 17:02:07serhiy.storchakasetmessages: + msg344840
2019-06-06 16:41:31tim.peterssetmessages: + msg344837
2019-06-06 16:36:49serhiy.storchakasetmessages: + msg344835
2019-06-06 16:30:28rhettingercreate