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

One argument form of math.perm() #81359

Closed
rhettinger opened this issue Jun 6, 2019 · 7 comments
Closed

One argument form of math.perm() #81359

rhettinger opened this issue Jun 6, 2019 · 7 comments
Labels
3.8 3.9 stdlib Python modules in the Lib dir

Comments

@rhettinger
Copy link
Contributor

rhettinger commented Jun 6, 2019

BPO 37178
Nosy @tim-one, @rhettinger, @mdickinson, @serhiy-storchaka
PRs
  • bpo-37178: Allow a one argument form of math.perm() #13905
  • [3.8] bpo-37178: Allow a one argument form of math.perm() (GH-13905) #13919
  • 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-08.23:55:34.895>
    created_at = <Date 2019-06-06.16:30:28.309>
    labels = ['3.8', 'library', '3.9']
    title = 'One argument form of math.perm()'
    updated_at = <Date 2019-06-08.23:55:34.895>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2019-06-08.23:55:34.895>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-08.23:55:34.895>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2019-06-06.16:30:28.309>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37178
    keywords = ['patch']
    message_count = 7.0
    messages = ['344833', '344835', '344837', '344840', '345020', '345053', '345054']
    nosy_count = 4.0
    nosy_names = ['tim.peters', 'rhettinger', 'mark.dickinson', 'serhiy.storchaka']
    pr_nums = ['13905', '13919']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37178'
    versions = ['Python 3.8', 'Python 3.9']

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Jun 6, 2019

    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.

    @rhettinger rhettinger added 3.8 3.9 stdlib Python modules in the Lib dir labels Jun 6, 2019
    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Jun 6, 2019

    perm(n, n) = factorial(n)

    @tim-one
    Copy link
    Member

    tim-one commented Jun 6, 2019

    I agree: perm(n) should return factorial(n).

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Jun 6, 2019

    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.

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Jun 8, 2019

    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.

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Jun 8, 2019

    New changeset e119b3d by Raymond Hettinger in branch 'master':
    bpo-37178: Allow a one argument form of math.perm() (GH-13905)
    e119b3d

    @rhettinger
    Copy link
    Contributor Author

    rhettinger commented Jun 8, 2019

    New changeset feaceaa by Raymond Hettinger (Miss Islington (bot)) in branch '3.8':
    bpo-37178: Allow a one argument form of math.perm() (GH-13905) (GH-13919)
    feaceaa

    @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 3.9 stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants