You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate using math.factorial() with floats #81496
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=Noneclosed_at=<Date2019-06-17.14:02:26.198>created_at=<Date2019-06-17.08:49:55.455>labels= ['extension-modules', 'type-feature', '3.9']
title='Deprecate using math.factorial() with floats'updated_at=<Date2019-06-17.14:02:26.198>user='https://github.com/serhiy-storchaka'
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.
Activity
serhiy-storchaka commentedon Jun 17, 2019
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.
mdickinson commentedon Jun 17, 2019
+1 from me; let's make
factorialconsistent with the other integer-based math module functions.serhiy-storchaka commentedon Jun 17, 2019
New changeset 231aad3 by Serhiy Storchaka in branch 'master':
bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)
231aad3