classification
Title: Deprecate using math.factorial() with floats
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mark.dickinson, pablogsal, rhettinger, serhiy.storchaka, stutzbach
Priority: normal Keywords: patch

Created on 2019-06-17 08:49 by serhiy.storchaka, last changed 2019-06-17 14:02 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14147 merged serhiy.storchaka, 2019-06-17 09:01
Messages (3)
msg345828 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-17 08:49
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 issue7550. 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 issue33083.
msg345842 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-06-17 10:48
+1 from me; let's make `factorial` consistent with the other integer-based  math module functions.
msg345859 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-17 13:57
New changeset 231aad38493c871dd32930a21d256cbacd2ae20c by Serhiy Storchaka in branch 'master':
bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)
https://github.com/python/cpython/commit/231aad38493c871dd32930a21d256cbacd2ae20c
History
Date User Action Args
2019-06-17 14:02:26serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-17 13:57:58serhiy.storchakasetmessages: + msg345859
2019-06-17 10:48:32mark.dickinsonsetmessages: + msg345842
2019-06-17 09:01:16serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request13988
2019-06-17 08:49:55serhiy.storchakacreate