python / python/cpython

Decide on fate of missing C23 math.h functions

Ouverte
#150,646 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

extension-modules type-feature
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lire le contexte du module math de Python et les références C23 liées dans l’issue, puis examinez l’issue de continuation #135853 et la discussion dans #150534. Le travail n’est pas encore prêt pour l’implémentation : il sera considéré comme terminé lorsqu’une décision aura été prise quant aux fonctions, changements de noms ou changements sémantiques répertoriés que Python devrait adopter.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c, python
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
Calme
Clarté
À clarifier
Accessibilité débutants
28/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.