Title: Add 'half turns' functions (cospi et al) to math module following C23 & IEEE754-2019 · Issue #150534 · python/cpython · GitHub
Open Graph Title: Add 'half turns' functions (cospi et al) to math module following C23 & IEEE754-2019 · Issue #150534 · python/cpython
X Title: Add 'half turns' functions (cospi et al) to math module following C23 & IEEE754-2019 · Issue #150534 · python/cpython
Description: Feature or enhancement Proposal: C23 standardized multiple new trig functions in
Open Graph Description: Feature or enhancement Proposal: C23 standardized multiple new trig functions in
X Description: Feature or enhancement Proposal: C23 standardized multiple new trig functions in <math.h> that operate on units of “half turns”. These functions are recommended by IEEE754-2019. I propose add...
Opengraph URL: https://github.com/python/cpython/issues/150534
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add 'half turns' functions (cospi et al) to math module following C23 & IEEE754-2019","articleBody":"# Feature or enhancement\n\n### Proposal:\n\n[C23 standardized](https://en.wikipedia.org/wiki/C23_(C_standard_revision)#:~:text=IEEE%20754%2D2019) multiple new trig functions in `\u003cmath.h>` that operate on units of “half turns”. These functions are recommended by IEEE754-2019. I propose adding these functions to CPython.\n\nThese function can be both more accurate and more performant than the traditional functions which take radian arguments, because inexact range reduction (e.g., modulo 2π) can be replaced by exact calculations (e.g., `fmod(x, 2)`) that never require excess precision.\n\nModern Linux systems such as Debian Trixie using glibc 2.41 include an implementation of all these C23 functions (regardless of whether building in C23 mode).\n\nFor instance, consider calculating the sine of 500π or 500 half-turns. The result is exactly zero with a proper `math.sinpi` implementation but nonzero with the traditional `math.sin` function, because 500π is not an exact FP number:\n\n```py\n>>> math.sinpi(500), math.sin(math.pi*500)\n(0.0, -1.6070832296378168e-13)\n```\n\nFor platforms which do not directly support these functions, for instance because they do not support the C23 standard or do not provide the functions when not building in C23 mode, implementations similar to the existing internal function `mathmodule.c` function `m_sinpi` can be used. These perform range reduction with `fmod` & special value checking before delegating to a platform radians-based routine (e.g., m_sinpi → `sin()` or `cos()`) with necessary scaling by a factor of π.\n\nI have prototyped this addition. You can view it on github: https://github.com/python/cpython/compare/main...jepler:cpython:c23-math-pifuns?expand=1#diff\n\nThis branch includes new tests & documentation for the new functions.\n\n### Has this already been discussed elsewhere?\n\nI have already discussed this feature proposal on Discourse\n\n### Links to previous discussion of this feature:\n\nhttps://discuss.python.org/t/add-half-turns-functions-cospi-et-al-to-math-module/107550 [no replies yet]\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-150555\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/jepler","@type":"Person","name":"jepler"},"datePublished":"2026-05-27T19:28:32Z","url":"https://github.com/python/cpython/issues/150534"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1388a591-98df-beee-5033-9bcf7b2b9328 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6A2:26ECEB:3D9B663:4E4A027:6B01FA69 |
| html-safe-nonce | f6c41f6e545c3993fb4643a7dfca9d9c5ed490e622f71705d0568624878592ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkEyOjI2RUNFQjozRDlCNjYzOjRFNEEwMjc6NkIwMUZBNjkiLCJ2aXNpdG9yX2lkIjoiNTMwNDg5MjAyMzgxMDE2MTI1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b3ef7e7772b9ddce0d78c683fe59f9dd664ca6f41d3569f6a7ffd89e852af913 |
| hovercard-subject-tag | issue:4535146587 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/150534/issue_layout |
| twitter:image | https://opengraph.githubassets.com/35890929adce168e3a08985cd678fb1fe7157251578ec5a2c1c256ae927a887f/python/cpython/issues/150534 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/35890929adce168e3a08985cd678fb1fe7157251578ec5a2c1c256ae927a887f/python/cpython/issues/150534 |
| og:image:alt | Feature or enhancement Proposal: C23 standardized multiple new trig functions in |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jepler |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width