Skip to content

Deprecate using math.factorial() with floats #81496

Closed

Description

@serhiy-storchaka
BPO 37315
Nosy @rhettinger, @mdickinson, @serhiy-storchaka, @pablogsal
PRs
  • bpo-37315: Deprecate accepting floats in math.factorial(). #14147
  • 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-17.14:02:26.198>
    created_at = <Date 2019-06-17.08:49:55.455>
    labels = ['extension-modules', 'type-feature', '3.9']
    title = 'Deprecate using math.factorial() with floats'
    updated_at = <Date 2019-06-17.14:02:26.198>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-06-17.14:02:26.198>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-17.14:02:26.198>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2019-06-17.08:49:55.455>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37315
    keywords = ['patch']
    message_count = 3.0
    messages = ['345828', '345842', '345859']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'stutzbach', 'serhiy.storchaka', 'pablogsal']
    pr_nums = ['14147']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37315'
    versions = ['Python 3.9']

    Activity

    1. serhiy-storchaka commented on Jun 17, 2019

      @serhiy-storchaka
      MemberAuthor

      Currently math.factorial() accepts integer-like objects (including objects with defined __index__) as well as float instances with integral value (but not arbitrary float-like objects with defined __float__). I suppose this was happen because factorial() was the first integer functions in the math module, and all other functions accepted floats at that time. See also bpo-7550. But now we have more pure integer functions in the math module: gcd, isqrt, comb, perm. Seems accepting floats in factorial was a mistake. Now we can fix it, and deprecate using factorial() with floats.

      Initial version of factorial() accepted also non-integral numbers (except float) with defined __int__. It was fixed in bpo-33083.

    2. mdickinson commented on Jun 17, 2019

      @mdickinson
      Member

      +1 from me; let's make factorial consistent with the other integer-based math module functions.

    3. serhiy-storchaka commented on Jun 17, 2019

      @serhiy-storchaka
      MemberAuthor

      New changeset 231aad3 by Serhiy Storchaka in branch 'master':
      bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)
      231aad3

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions