Skip to content
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

Add math.perm() #81309

Closed
serhiy-storchaka opened this issue Jun 1, 2019 · 4 comments
Closed

Add math.perm() #81309

serhiy-storchaka opened this issue Jun 1, 2019 · 4 comments
Labels
3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 37128
Nosy @malemburg, @rhettinger, @mdickinson, @serhiy-storchaka
PRs
  • bpo-37128: Add math.perm(). #13731
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-06-02.08:53:34.710>
    created_at = <Date 2019-06-01.20:47:29.810>
    labels = ['3.8', 'type-feature', 'library']
    title = 'Add math.perm()'
    updated_at = <Date 2019-06-02.08:53:41.312>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-06-02.08:53:41.312>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-02.08:53:34.710>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2019-06-01.20:47:29.810>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37128
    keywords = ['patch']
    message_count = 4.0
    messages = ['344226', '344227', '344228', '344259']
    nosy_count = 5.0
    nosy_names = ['lemburg', 'rhettinger', 'mark.dickinson', 'stutzbach', 'serhiy.storchaka']
    pr_nums = ['13731']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37128'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    The function which returns the number of ways to choose k items from n items without repetition and without order was added in bpo-35431. 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().

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 1, 2019
    @rhettinger
    Copy link
    Contributor

    +0 from me. It is inevitable that this will be requested now that we have comb(). The need for this is much less though.

    @mdickinson
    Copy link
    Member

    +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).

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 5ae299a by Serhiy Storchaka in branch 'master':
    bpo-37128: Add math.perm(). (GH-13731)
    5ae299a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants