Title: Speed up float encoding in `json` · Issue #159702 · python/cpython · GitHub
Open Graph Title: Speed up float encoding in `json` · Issue #159702 · python/cpython
X Title: Speed up float encoding in `json` · Issue #159702 · python/cpython
Description: Feature or enhancement I ran a throughput benchmark for different json libraries. Float encoding is a particularly weak area for the json library, especially for large-magnitude floats. Would it be possible to optimize this by adding a s...
Open Graph Description: Feature or enhancement I ran a throughput benchmark for different json libraries. Float encoding is a particularly weak area for the json library, especially for large-magnitude floats. Would it be...
X Description: Feature or enhancement I ran a throughput benchmark for different json libraries. Float encoding is a particularly weak area for the json library, especially for large-magnitude floats. Would it be...
Opengraph URL: https://github.com/python/cpython/issues/159702
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Speed up float encoding in `json`","articleBody":"### Feature or enhancement\n\nI ran a [throughput benchmark](https://jsonyx.readthedocs.io/en/latest/benchmark.html) for different json libraries.\n\nFloat encoding is a particularly weak area for the `json` library, especially for large-magnitude floats. Would it be possible to optimize this by adding a special case to `PyUnicodeWriter_WriteRepr()`, similar to `_PyLong_FormatWriter()` for integers?\n\n| encode | json | jsonyx | fastsimdjson | msgspec | orjson | fastest time |\n|:--------------------------|-------:|-------:|-------------:|--------:|---------:|-------------:|\n| `0.0` | 12.68x | 14.10x | 1.32x | 1.00x | 1.11x | 7.32 ns |\n| `1e-05` | 13.05x | 13.47x | 1.12x | 1.81x | 1.00x | 29.43 ns |\n| `5e-324` | 25.71x | 26.07x | 1.07x | 1.00x | 1.33x | 24.83 ns |\n| `1.7976931348623157e+308` | 79.89x | 80.30x | 1.00x | 1.28x | 1.03x | 30.29 ns |\n\ncc @vstinner\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159826\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/nineteendo","@type":"Person","name":"nineteendo"},"datePublished":"2026-10-19T10:59:56Z","url":"https://github.com/python/cpython/issues/159702"}
| 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:ababc709-644d-e057-22ff-626f36ec7d87 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE6A:19B6A2:1308351:192CE9B:6B01EDFA |
| html-safe-nonce | 0a77caaf60607cdaf700ae1674151d2ea27977102ea901162ebcabb78c293285 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTZBOjE5QjZBMjoxMzA4MzUxOjE5MkNFOUI6NkIwMUVERkEiLCJ2aXNpdG9yX2lkIjoiOTA0OTUxODgxOTEzOTI1MTcwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5f2c78e45cfc4a14244e592f3dfcea0d92f66eb2b46e072ed27e04223e0eb909 |
| hovercard-subject-tag | issue:5922603476 |
| 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/159702/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d45665dee5e06c09c5d6f326bef124375bbfaf2f380f6817a739403989396b91/python/cpython/issues/159702 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d45665dee5e06c09c5d6f326bef124375bbfaf2f380f6817a739403989396b91/python/cpython/issues/159702 |
| og:image:alt | Feature or enhancement I ran a throughput benchmark for different json libraries. Float encoding is a particularly weak area for the json library, especially for large-magnitude floats. Would it be... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nineteendo |
| 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