python / python/cpython

Decide on fate of missing C23 math.h functions

未關閉
#150,646 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

extension-modules type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Feature or enhancement

Proposal:

With https://github.com/python/cpython/issues/150534 it seems that sinpi et all will be landed in the math module. Lets discuss here remaining functions, coming with C23:

  • exp10 - The exp10 functions compute the base-10 exponential of x.
  • exp2m1 - The exp2m1 functions compute the base-2 exponential of the argument, minus 1.
  • exp10m1 - The exp10m1 functions compute the base-10 exponential of the argument, minus 1.
  • log2p1 - The log2p1 functions compute the base-2 logarithm of 1 plus the argument.
  • log10p1 - The log10p1 functions compute the base-10 logarithm of 1 plus the argument.
  • logp1 - alias of log1p, should we consider renaming?
  • rootn - The rootn functions compute the principal nth root of x.
  • rsqrt - The rsqrt functions compute the reciprocal of the nonnegative square root of the argument.

For completeness, cases that can change semantics of pow():

  • pown - The pown functions compute x raised to the nth power.
  • powr - The powr functions compute x raised to the power y as e**(y*log(x)).

References:

CC @picnixz, @rhettinger, @tim-one

I think that missing exp/log functions are good addition on same ground, as existing functions. log1p can be soft-deprecated (I don't think it worth considering deviations in naming like log1p2 and log1p10). I'm less certain about rootn (seems useful, but I would prefer rather some cmath function, that can return any k-th from n roots) and rsqrt.

Consider this as a continuation of https://github.com/python/cpython/issues/135853.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先閱讀 Python math 模組的脈絡以及 issue 中連結的 C23 參考資料,然後檢視後續 issue #135853 與 #150534 中的討論。目前這項工作尚未達到可以實作的程度:完成的標準是就 Python 應採用所列出的哪些函式、命名變更或語意變更作出決定。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
c, python
領域
api, backend
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
冷清
描述清晰度
需要釐清
新手友好度
28/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。