René's URL Explorer Experiment


Title: Improve `printf`-style formatting docs for non-built-in types · Issue #142108 · python/cpython · GitHub

Open Graph Title: Improve `printf`-style formatting docs for non-built-in types · Issue #142108 · python/cpython

X Title: Improve `printf`-style formatting docs for non-built-in types · Issue #142108 · python/cpython

Description: Add a description about how Decimal behaves differently with format and % formatting in https://docs.python.org/3/library/string.html#format-specification-mini-language For __format__, Decimal is formatted with the highest possible preci...

Open Graph Description: Add a description about how Decimal behaves differently with format and % formatting in https://docs.python.org/3/library/string.html#format-specification-mini-language For __format__, Decimal is f...

X Description: Add a description about how Decimal behaves differently with format and % formatting in https://docs.python.org/3/library/string.html#format-specification-mini-language For __format__, Decimal is f...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve `printf`-style formatting docs for non-built-in types","articleBody":"# Add a description about how Decimal behaves differently with __format__ and % formatting in https://docs.python.org/3/library/string.html#format-specification-mini-language\n\nFor \\_\\_format\\_\\_, Decimal is formatted ~~with the highest possible precision~~ as it is.\n\nFor % formatting, Decimal is converted to float before formatting.\n\nThese behaviors have not changed since they were added.\n- The Decimal class was added in Python 2.4 (https://docs.python.org/2.4/whatsnew/whatsnew24.html).\n- The \\_\\_format\\_\\_ method was added in Python 2.6 (https://docs.python.org/2.6/whatsnew/2.6.html).\n\nCompare:\n| `sys.version` | `'%f' % 11111111111111111111.0` | `'%f' % Decimal('11111111111111111111.0')` | `Decimal('11111111111111111111.0').__format__('f')` | `'%e' % 0.0` | `'%e' % Decimal('0.0')` | `Decimal('0.0').__format__('e')` | `'%.20e' % 11111111111111111111.0` | `'%.20e' % Decimal('11111111111111111111.0')` | `Decimal('11111111111111111111.0').__format__('.20e')` | `'%.20g' % 11111111111111111111.0` | `'%.20g' % Decimal('11111111111111111111.0')` | `Decimal('11111111111111111111.0').__format__('.20g')` |\n| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |\n| '2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]' | '11111111111111111000.000000' | '11111111111111111000.000000' | Exception | '0.000000e+000' | '0.000000e+000' | Exception | '1.11111111111111110000e+019' | '1.11111111111111110000e+019' | Exception | '11111111111111111000' | '11111111111111111000' | Exception |\n| '2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)]' | '11111111111111111000.000000' | '11111111111111111000.000000' | '11111111111111111111.0' | '0.000000e+00' | '0.000000e+00' | '0e-1' | '1.11111111111111110000e+19' | '1.11111111111111110000e+19' | '1.11111111111111111110e+19' | '11111111111111111000' | '11111111111111111000' | '11111111111111111111' |\n| '2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]' | '11111111111111110656.000000' | '11111111111111110656.000000' | '11111111111111111111.0' | '0.000000e+00' | '0.000000e+00' | '0e-1' | '1.11111111111111106560e+19' | '1.11111111111111106560e+19' | '1.11111111111111111110e+19' | '11111111111111110656' | '11111111111111110656' | '11111111111111111111' |\n| '3.14.0 (tags/v3.14.0:ebf955d, Oct  7 2025, 10:06:33) [MSC v.1944 32 bit (Intel)]' | '11111111111111110656.000000' | '11111111111111110656.000000' | '11111111111111111111.0' | '0.000000e+00' | '0.000000e+00' | '0e-1' | '1.11111111111111106560e+19' | '1.11111111111111106560e+19' | '1.11111111111111111110e+19' | '11111111111111110656' | '11111111111111110656' | '11111111111111111111' |\n| '3.14.0 (tags/v3.14.0:ebf955d, Oct  7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)]' | '11111111111111110656.000000' | '11111111111111110656.000000' | '11111111111111111111.0' | '0.000000e+00' | '0.000000e+00' | '0e-1' | '1.11111111111111106560e+19' | '1.11111111111111106560e+19' | '1.11111111111111111110e+19' | '11111111111111110656' | '11111111111111110656' | '11111111111111111111' |\n| '3.15.0a2 (tags/v3.15.0a2:a625628, Nov 18 2025, 18:12:01) [MSC v.1944 64 bit (AMD64)]' | '11111111111111110656.000000' | '11111111111111110656.000000' | '11111111111111111111.0' | '0.000000e+00' | '0.000000e+00' | '0e-1' | '1.11111111111111106560e+19' | '1.11111111111111106560e+19' | '1.11111111111111111110e+19' | '11111111111111110656' | '11111111111111110656' | '11111111111111111111' |\n\n```python\n# ./test.py\nimport sys\nfrom decimal import Decimal\n\nfor expr in (\n    \"sys.version\",\n\n    \"'%f' % 12345123451234512345.0\",\n    \"'%f' % Decimal('12345123451234512345.0')\",\n    \"Decimal('12345123451234512345.0').__format__('f')\",\n\n    \"'%e' % 0.0\",\n    \"'%e' % Decimal('0.0')\",\n    \"Decimal('0.0').__format__('e')\",\n\n    \"'%.20e' % 12345123451234512345.0\",\n    \"'%.20e' % Decimal('12345123451234512345.0')\",\n    \"Decimal('12345123451234512345.0').__format__('.20e')\",\n\n    \"'%.20g' % 12345123451234512345.0\",\n    \"'%.20g' % Decimal('12345123451234512345.0')\",\n    \"Decimal('12345123451234512345.0').__format__('.20g')\",\n):\n    print(expr)\n    try:\n        print(repr(eval(expr)))\n    except Exception:\n        print('Exception')\n    print('')\n```\n\n```python\n# ./test_runner.py\nfrom pathlib import Path\nfrom subprocess import run, PIPE\n\nPYTHON_DIR_ROOT = r\"C:\\python_dir_root\"\n\ndef print_row(row, file):\n    for v in row: print(f\"| {v} \", end='', file=file)\n    print(\"|\", file=file)\n\ndef print_md_table(headers, rows, file):\n    print_row(headers, file=file)\n    print_row(['---:'] * len(headers), file=file)\n    for row in rows: print_row(row, file=file)\n    print(file=file)\n\nrows = []\nfor dir in Path(PYTHON_DIR_ROOT).iterdir():\n    out = run([str(dir/\"python.exe\"), \"./test.py\"], stdout=PIPE).stdout\n    out = out.decode('utf-8').splitlines()\n    headers = [f\"`{h}`\" for h in out[::3]]\n    rows.append(out[1::3])\n\nwith open(\"./test_result.md\", 'w', encoding='utf-8') as fp:\n    print_md_table(headers, rows, file=fp)\n```\n\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142117\n* gh-142126\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/1nftf","@type":"Person","name":"1nftf"},"datePublished":"2025-11-30T08:54:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/142108/cpython/issues/142108"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:866acf49-83e3-117d-d007-d5b78e99a078
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB966:CED76:5EC224:837AA7:696A78BE
html-safe-noncea8a77bd0df3a2b1fa8064af5aebeeb6899f32b8dd3a66a6a303a22862dc64cdf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTY2OkNFRDc2OjVFQzIyNDo4MzdBQTc6Njk2QTc4QkUiLCJ2aXNpdG9yX2lkIjoiNTM0MzgwNzgyMDUwOTM3ODc1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5502447cc6256aa1e692a2b89ce41449be06f096c552fa95b7201aca40904e07
hovercard-subject-tagissue:3677538450
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/142108/issue_layout
twitter:imagehttps://opengraph.githubassets.com/da80d1e4e7c2e3b0cb1531f4ea4c3b02d7907b059a4de34a56ae824a6d2e76a3/python/cpython/issues/142108
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/da80d1e4e7c2e3b0cb1531f4ea4c3b02d7907b059a4de34a56ae824a6d2e76a3/python/cpython/issues/142108
og:image:altAdd a description about how Decimal behaves differently with format and % formatting in https://docs.python.org/3/library/string.html#format-specification-mini-language For __format__, Decimal is f...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:username1nftf
hostnamegithub.com
expected-hostnamegithub.com
None5b774e44f85c14a75886edd04ddda4e5a25ddebbb241bcbb590b08a3048730e8
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
releasecc5f4eee261b3601c1e98e217ceaf28508b9567e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/142108#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142108
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142108
Sign up https://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/142108
Reloadhttps://github.com/python/cpython/issues/142108
Reloadhttps://github.com/python/cpython/issues/142108
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/142108
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/142108
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142108
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142108
Improve printf-style formatting docs for non-built-in typeshttps://github.com/python/cpython/issues/142108#top
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
https://github.com/1nftf
https://github.com/1nftf
1nftfhttps://github.com/1nftf
on Nov 30, 2025https://github.com/python/cpython/issues/142108#issue-3677538450
https://docs.python.org/3/library/string.html#format-specification-mini-languagehttps://docs.python.org/3/library/string.html#format-specification-mini-language
https://docs.python.org/2.4/whatsnew/whatsnew24.htmlhttps://docs.python.org/2.4/whatsnew/whatsnew24.html
https://docs.python.org/2.6/whatsnew/2.6.htmlhttps://docs.python.org/2.6/whatsnew/2.6.html
#71https://github.com/python/cpython/pull/71
gh-142108: Document Decimal formatting behavior differences #142117https://github.com/python/cpython/pull/142117
gh-142108: document conversion rules for printf-style formatting #142126https://github.com/python/cpython/pull/142126
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
docs issueshttps://github.com/orgs/python/projects/52
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.