Title: Fastpath for encoding unsorted dict to JSON · Issue #95385 · python/cpython · GitHub
Open Graph Title: Fastpath for encoding unsorted dict to JSON · Issue #95385 · python/cpython
X Title: Fastpath for encoding unsorted dict to JSON · Issue #95385 · python/cpython
Description: JSON encoder can produce output sorted by key (json.dumps(sort_keys=True)) The default value for sort_keys is False. The code always creates a list of dictionary items, sorts them if needed, and then iterates through them. However, if so...
Open Graph Description: JSON encoder can produce output sorted by key (json.dumps(sort_keys=True)) The default value for sort_keys is False. The code always creates a list of dictionary items, sorts them if needed, and th...
X Description: JSON encoder can produce output sorted by key (json.dumps(sort_keys=True)) The default value for sort_keys is False. The code always creates a list of dictionary items, sorts them if needed, and th...
Opengraph URL: https://github.com/python/cpython/issues/95385
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fastpath for encoding unsorted dict to JSON","articleBody":"JSON encoder can produce output sorted by key (`json.dumps(sort_keys=True)`) The default value for `sort_keys` is `False`. The code always creates a list of dictionary items, sorts them if needed, and then iterates through them.\r\nHowever, if sorting is not requested we can use `PyDict_Next` to avoid allocating a list of tuples.\r\n\r\npyperformance on my machine before changes:\r\n\r\n```\r\n### json_dumps ###\r\nMean +- std dev: 10.6 ms +- 0.1 ms\r\n```\r\n\r\npyperformance after changes:\r\n\r\n```\r\n### json_dumps ###\r\nMean +- std dev: 9.00 ms +- 0.08 ms\r\n```","author":{"url":"https://github.com/aivarsk","@type":"Person","name":"aivarsk"},"datePublished":"2022-07-28T14:09:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/95385/cpython/issues/95385"}
| 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:2eb8ca50-bebc-236c-8dd2-eef1224f761c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A04E:5177D:1F1AF0B:2B6196F:696937DF |
| html-safe-nonce | 5c46ef0bc9368874d9260a6ac8961bd7527b02498bdbcc22f2506142d729d60a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDRFOjUxNzdEOjFGMUFGMEI6MkI2MTk2Rjo2OTY5MzdERiIsInZpc2l0b3JfaWQiOiI3Mzg3NjUzNjM3MDczODc2OTU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 833018758058c20a8d15bdcd27bea8b0e6b62957cec642d82dc73f262896cb8f |
| hovercard-subject-tag | issue:1320992061 |
| 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/95385/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f85f8689f53482e0d43cc5c221bd783425053b7687c30f80364f7588e958f38/python/cpython/issues/95385 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f85f8689f53482e0d43cc5c221bd783425053b7687c30f80364f7588e958f38/python/cpython/issues/95385 |
| og:image:alt | JSON encoder can produce output sorted by key (json.dumps(sort_keys=True)) The default value for sort_keys is False. The code always creates a list of dictionary items, sorts them if needed, and th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aivarsk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| 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 | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width