classification
Title: Add math.perm()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach
Priority: normal Keywords: patch

Created on 2019-06-01 20:47 by serhiy.storchaka, last changed 2019-06-02 08:53 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13731 merged serhiy.storchaka, 2019-06-01 20:49
Messages (4)
msg344226 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-01 20:47
The function which returns the number of ways to choose k items from n items without repetition and without order was added in issue35431. This functions is always goes in pair with other function, which returns the number of ways to choose k items from n items without repetition and with order. These functions are always learned together in curses of combinatorics. Often C(n,k) is determined via P(n,k) (and both are determined via factorial).

    P(n, k) = n! / (n-k)!
    C(n, k) = P(n, k) / k!

The proposed PR adds meth.perm(). It shares most of the code with math.comb().
msg344227 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-06-01 20:49
+0 from me.  It is inevitable that this will be requested now that we have comb().  The need for this is much less though.
msg344228 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-06-01 20:54
> +0 from me.  It is inevitable that this will be requested now that we have comb().

Exactly my thoughts, too. I don't think I'll have any use for `math.perm`; the main reason to add it will be to satisfy all those who got taught combinations and permutations at the same time, see them as a unit, and then get surprised when they find `math.comb` without `math.perm`.

The good part is that now that we have math.comb, I think everything about the API of math.perm is already clear (including what to call it).
msg344259 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-02 08:17
New changeset 5ae299ac78abb628803ab7dee0997364547f5cc8 by Serhiy Storchaka in branch 'master':
bpo-37128: Add math.perm(). (GH-13731)
https://github.com/python/cpython/commit/5ae299ac78abb628803ab7dee0997364547f5cc8
History
Date User Action Args
2019-06-02 08:53:41serhiy.storchakasetresolution: fixed
2019-06-02 08:53:34serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
2019-06-02 08:17:04serhiy.storchakasetmessages: + msg344259
2019-06-01 20:54:40mark.dickinsonsetmessages: + msg344228
2019-06-01 20:49:22serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request13615
2019-06-01 20:49:09rhettingersetnosy: + rhettinger
messages: + msg344227
2019-06-01 20:47:29serhiy.storchakacreate