python / python/cpython

Decide on fate of missing C23 math.h functions

オープン
#150,646 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

extension-modules type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず Python の math モジュールのコンテキストと issue にリンクされている C23 のリファレンスを読み、続いて継続 issue #135853 と #150534 の議論を確認してください。作業はまだ実装の準備ができていません。完了とは、列挙された関数、命名変更、または意味上の変更のうち、Python がどれを採用すべきかについて決定に達することを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, python
領域
api, backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
28/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。