René's URL Explorer Experiment


Title: Conditionally support native half-precision IEEE types in struct/array/ctypes modules and memoryview · Issue #153740 · python/cpython · GitHub

Open Graph Title: Conditionally support native half-precision IEEE types in struct/array/ctypes modules and memoryview · Issue #153740 · python/cpython

X Title: Conditionally support native half-precision IEEE types in struct/array/ctypes modules and memoryview · Issue #153740 · python/cpython

Description: Feature or enhancement Proposal: Both gcc (since v12) and clang (since v14) have support for the _Float16 (i.e. partial support for Annex H of the C23). Complex half-precision type also supported by mentioned compilers. I think, we could...

Open Graph Description: Feature or enhancement Proposal: Both gcc (since v12) and clang (since v14) have support for the _Float16 (i.e. partial support for Annex H of the C23). Complex half-precision type also supported b...

X Description: Feature or enhancement Proposal: Both gcc (since v12) and clang (since v14) have support for the _Float16 (i.e. partial support for Annex H of the C23). Complex half-precision type also supported b...

Opengraph URL: https://github.com/python/cpython/issues/153740

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conditionally support native half-precision IEEE types in struct/array/ctypes modules and memoryview","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nBoth gcc (since v12) and clang (since v14) have support for the _Float16 (i.e. partial support for Annex H of the C23).  Complex half-precision type also supported by mentioned compilers.  I think, we could utilize that and enable using native half-precision types conditionally in the ctypes module, like we do for complex types.  For the rest (struct/array/memoryview) - half-precision types will be enabled unconditionally.\n\nToDo:\n- [x] modify PyFloat_Pack2/PyFloat_Unpack2 to use native 16-bit type, if available // https://github.com/python/cpython/pull/154796\n- [ ] ~~support `'Ze'` type in the struct module // https://github.com/python/cpython/pull/156805~~\n- [ ] ~~suppprt `'Ze'` type in the array module // https://github.com/python/cpython/pull/156805~~\n- [ ] ~~support `'Ze'` type in the memoryview~~\n- [ ] ~~add support for `'e'` (`_Float16`) to the ctypes module~~\n- [ ] ~~add support for `'Ze'` (`_Float16 _Complex`) to the ctypes module~~\n\nLast two tasks looks less trivial, as the libffi has no support for `_Float16` type.  Does this prevents us from adding such type or we can include workarounds for the libffi to the CPython itself?\n\n\u003cdetails>\n\nFollowing works on x86:\n```\n$ cat a.c\n#define __STDC_WANT_IEC_60559_TYPES_EXT__\n#include \u003cmath.h>\n#include \u003cstdio.h>\n#include \u003cstring.h>\n\n#include \u003cffi.h>\n\n_Float16 myexp(_Float16 x)\n{\n    return 1 + x;\n}\n\nint main(void)\n{\n    _Float16 f16 = 1.23e3;\n    void *values[1] = {&f16};\n    float res;\n    _Float16 res2;\n    ffi_type *args[1] = {&ffi_type_float};\n    ffi_cif cif;\n\n    if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,\n        &ffi_type_float, args) != FFI_OK)\n    {\n        return 1;\n    }\n    ffi_call(&cif, FFI_FN(myexp), &res, values);\n    memcpy(&res2, &res, 2); /* fixup, assuming LE */\n    printf(\"%e\\n\", (double)res2);\n    return 0;\n}\n$ gcc a.c -Wall -lm -lffi && ./a.out\n1.231000e+03\n```\n\n\u003c/details>\n\n\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/106723\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-154796\n* gh-156805\n* gh-156815\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/skirpichev","@type":"Person","name":"skirpichev"},"datePublished":"2026-07-15T05:01:28Z","url":"https://github.com/python/cpython/issues/153740"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:18b204d4-431b-6301-aad1-f19b8af877b7
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDF86:4279A:31B8E94:42DD580:6B020780
html-safe-nonce4a02c8bebe201e41f0ca88891f5a4c33a0f5ef16e545490848e3920279206982
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjg2OjQyNzlBOjMxQjhFOTQ6NDJERDU4MDo2QjAyMDc4MCIsInZpc2l0b3JfaWQiOiI4MDgxMDA5NDMxOTY3NTY1Njk2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc2b032678a76bd84d315cb894860d6534dc20f714f3f52c21055f618c6c8ff0d
hovercard-subject-tagissue:4889438016
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/153740/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5a3dd447fa258a89972953e8630a13358c6dc597f67fb58015a2cc8176996015/python/cpython/issues/153740
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5a3dd447fa258a89972953e8630a13358c6dc597f67fb58015a2cc8176996015/python/cpython/issues/153740
og:image:altFeature or enhancement Proposal: Both gcc (since v12) and clang (since v14) have support for the _Float16 (i.e. partial support for Annex H of the C23). Complex half-precision type also supported b...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameskirpichev
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/153740#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153740
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153740
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/153740
Reloadhttps://github.com/python/cpython/issues/153740
Reloadhttps://github.com/python/cpython/issues/153740
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153740
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153740
Conditionally support native half-precision IEEE types in struct/array/ctypes modules and memoryviewhttps://github.com/python/cpython/issues/153740#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Jul 15, 2026https://github.com/python/cpython/issues/153740#issue-4889438016
gh-153740: Optimize PyFloat_Pack/Unpack2 using native _Float16 #154796https://github.com/python/cpython/pull/154796
gh-153740: support _Float16 complex in struct/array modules #156805https://github.com/python/cpython/pull/156805
gh-153740: support _Float16 complex in struct/array modules #156805https://github.com/python/cpython/pull/156805
https://discuss.python.org/t/106723https://discuss.python.org/t/106723
gh-153740: Optimize PyFloat_Pack/Unpack2 using native _Float16 #154796https://github.com/python/cpython/pull/154796
gh-153740: support _Float16 complex in struct/array modules #156805https://github.com/python/cpython/pull/156805
gh-153740: refine test for _Float16 (check support from libm) #156815https://github.com/python/cpython/pull/156815
Nexthttps://github.com/python/cpython/issues/153740?timeline_page=1
skirpichevhttps://github.com/skirpichev
on Jul 15, 2026https://github.com/python/cpython/issues/153740#event-27998275855
skirpichevhttps://github.com/skirpichev
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Jul 15, 2026https://github.com/python/cpython/issues/153740#event-27998276244
serhiy-storchakahttps://github.com/serhiy-storchaka
Struct, memoryview and array issues 🏗️https://github.com/orgs/python/projects/65
on Jul 17, 2026https://github.com/python/cpython/issues/153740#event-28109371480
github-project-automationhttps://github.com/apps/github-project-automation
Struct, memoryview and array issues 🏗️https://github.com/orgs/python/projects/65
on Jul 17, 2026https://github.com/python/cpython/issues/153740
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jul 17, 2026https://github.com/python/cpython/issues/153740#issuecomment-5000420616
Struct, memoryview and array issues 🏗️https://github.com/orgs/python/projects/65
smithdc1https://github.com/smithdc1
on Jul 25, 2026https://github.com/python/cpython/issues/153740#event-28469807256
Refs #37055 -- Raised NotImplementedError for unsupported GDAL raster…https://github.com/smithdc1/django/commit/e073dd8ccefa36e653a5ce5ae8b1d951968dafe1
e073dd8https://github.com/smithdc1/django/commit/e073dd8ccefa36e653a5ce5ae8b1d951968dafe1
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Jul 30, 2026https://github.com/python/cpython/issues/153740#issuecomment-5125130700
#154796https://github.com/python/cpython/pull/154796
skirpichevhttps://github.com/skirpichev
on Jul 30, 2026https://github.com/python/cpython/issues/153740#event-28693843264
vstinnerhttps://github.com/vstinner
on Sep 1, 2026https://github.com/python/cpython/issues/153740#event-30347948507
gh-153740: Optimize PyFloat_Pack/Unpack2 using native _Float16 (#154796)https://github.com/python/cpython/commit/e7ef46acf6c6da08925b183f5894c502bcd43faf
gh-153740https://github.com/python/cpython/issues/153740
#154796https://github.com/python/cpython/pull/154796
e7ef46ahttps://github.com/python/cpython/commit/e7ef46acf6c6da08925b183f5894c502bcd43faf
skirpichevhttps://github.com/skirpichev
on Sep 1, 2026https://github.com/python/cpython/issues/153740#event-30348418387
https://github.com/encukou
encukouhttps://github.com/encukou
on Sep 2, 2026https://github.com/python/cpython/issues/153740#issuecomment-5507444478
#154796https://github.com/python/cpython/pull/154796
https://buildbot.python.org/all/#/builders/1232/builds/9446https://buildbot.python.org/all/#/builders/1232/builds/9446
skirpichevhttps://github.com/skirpichev
on Sep 2, 2026https://github.com/python/cpython/issues/153740#event-30410134112
pythongh-153740: refine test for _Float16 (check support from libm)https://github.com/skirpichev/cpython/commit/0567678636c46265af80b3e5be463539dd84b893
pythongh-153740https://github.com/python/cpython/issues/153740
0567678https://github.com/skirpichev/cpython/commit/0567678636c46265af80b3e5be463539dd84b893
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Sep 2, 2026https://github.com/python/cpython/issues/153740#issuecomment-5508917125
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Sep 2, 2026https://github.com/python/cpython/issues/153740#issuecomment-5509930735
#154796https://github.com/python/cpython/pull/154796
https://buildbot.python.org/all/#/builders/1232/builds/9446https://buildbot.python.org/all/#/builders/1232/builds/9446
#156815https://github.com/python/cpython/pull/156815
https://github.com/encukou
encukouhttps://github.com/encukou
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5522466915
the PRhttps://github.com/python/cpython/pull/156805
@skirpichevhttps://github.com/skirpichev
SC request in their issue #345https://github.com/python/steering-council/issues/345#issuecomment-4362321562
https://github.com/hpkfft
hpkffthttps://github.com/hpkfft
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5522816494
PEPhttps://peps.python.org/pep-3118/#additions-to-the-struct-string-syntax
@seberghttps://github.com/seberg
@pitrouhttps://github.com/pitrou
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5522901632
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5522907533
https://github.com/seberg
seberghttps://github.com/seberg
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5523044306
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5523732158
https://discuss.python.org/https://discuss.python.org/
skirpichevhttps://github.com/skirpichev
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
on Sep 3, 2026https://github.com/python/cpython/issues/153740#event-30478317334
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5523770483
@serhiy-storchakahttps://github.com/serhiy-storchaka
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Sep 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5523770879
https://discuss.python.org/https://discuss.python.org/
skirpichevhttps://github.com/skirpichev
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 3, 2026https://github.com/python/cpython/issues/153740#event-30478353136
github-project-automationhttps://github.com/apps/github-project-automation
Struct, memoryview and array issues 🏗️https://github.com/orgs/python/projects/65
on Sep 3, 2026https://github.com/python/cpython/issues/153740
clin1234https://github.com/clin1234
on Sep 12, 2026https://github.com/python/cpython/issues/153740#event-31023914301
pythongh-153740: Optimize PyFloat_Pack/Unpack2 using native _Float16 (p…https://github.com/clin1234/cpython/commit/c072b8624c3bab66c2e53606e7c98ced6172e097
pythongh-153740https://github.com/python/cpython/issues/153740
p…https://github.com/python/cpython/pull/154796
c072b86https://github.com/clin1234/cpython/commit/c072b8624c3bab66c2e53606e7c98ced6172e097
pythongh-153740: Refine test for _Float16: check support from libm (p…https://github.com/clin1234/cpython/commit/66a0dd91624ec7338c34502976fd090cd7754214
pythongh-153740https://github.com/python/cpython/issues/153740
p…https://github.com/python/cpython/pull/156815
66a0dd9https://github.com/clin1234/cpython/commit/66a0dd91624ec7338c34502976fd090cd7754214
https://github.com/hpkfft
hpkffthttps://github.com/hpkfft
on Oct 3, 2026https://github.com/python/cpython/issues/153740#issuecomment-5972226525
#154796 (comment)https://github.com/python/cpython/pull/154796#issuecomment-5111058501
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/153740#issuecomment-5974921685
@hpkffthttps://github.com/hpkfft
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/153740
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/153740
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
Struct, memoryview and array issues 🏗️https://github.com/orgs/python/projects/65
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.