Title: `sortperf.py` is broken · Issue #116576 · python/cpython · GitHub
Open Graph Title: `sortperf.py` is broken · Issue #116576 · python/cpython
X Title: `sortperf.py` is broken · Issue #116576 · python/cpython
Description: Bug report Bug description: It's supposed to measure sort speed for different kinds of data, from best to worst case. But currently it shows about the same speed for all kinds, because the same list object is sorted a thousand times. Whi...
Open Graph Description: Bug report Bug description: It's supposed to measure sort speed for different kinds of data, from best to worst case. But currently it shows about the same speed for all kinds, because the same lis...
X Description: Bug report Bug description: It's supposed to measure sort speed for different kinds of data, from best to worst case. But currently it shows about the same speed for all kinds, because the same...
Opengraph URL: https://github.com/python/cpython/issues/116576
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`sortperf.py` is broken","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nIt's supposed to measure sort speed for different kinds of data, from best to worst case. But currently it shows about the same speed for all kinds, because the same list object is sorted a thousand times. Which means all but the first sort are just sorting the already sorted list. And that dominates the total time, making the first=real sort insignificant.\r\n\r\nOddly it was specifically changed to be this way, [here](https://github.com/python/cpython/pull/114687/commits/7c2dd81535c67477188e9adf157f5fe158023ac8), from\r\n\r\n```python\r\n def _prepare_data(self, loops: int) -\u003e list[float]:\r\n bench = BENCHMARKS[self._name]\r\n return [\r\n bench(self._size, self._random)\r\n for _ in range(loops)\r\n ]\r\n```\r\nto:\r\n```python\r\n def _prepare_data(self, loops: int) -\u003e list[float]:\r\n bench = BENCHMARKS[self._name]\r\n return [bench(self._size, self._random)] * loops\r\n```\r\nThere was even a [comment](https://github.com/python/cpython/pull/114687#issuecomment-1945650107) showing that all cases from best to worst now take about the same tiny time 29.2 us, calling it an optimization (and I think it refers to the above change). So is this intentional/desired? I highly doubt that, but if it's a mistake, it's really weird.\r\n\r\nThe whole update was btw called *\"Move Lib/test/sortperf.py to Tools/scripts\"*, but in reality it wasn't just moved but completely rewritten. I don't think that was good, in my opinion moves should just be moves, not hide massive changes.\r\n\r\n@sobolevn @tim-one \r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-116577\n* gh-116582\n* gh-116583\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/pochmann3","@type":"Person","name":"pochmann3"},"datePublished":"2024-03-10T22:24:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/116576/cpython/issues/116576"}
| 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:5b7f695a-c8a4-cf73-698c-98dc443a79e4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD94:3C7D7F:17AE2E2:2083D91:696AAF1E |
| html-safe-nonce | 8a088681871eddb7c9aa8c7a13312ad0f3aa60658ff08b2050f540385271c386 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDk0OjNDN0Q3RjoxN0FFMkUyOjIwODNEOTE6Njk2QUFGMUUiLCJ2aXNpdG9yX2lkIjoiOTE5NTIxNDI0MTYyMDczMzcyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f09ab5da628c291de3c2159607246bc72236a7a04316c3539f10e5ab0ac34b16 |
| hovercard-subject-tag | issue:2177932232 |
| 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/116576/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc87196248d7f2b92d3010bee3035200a916e5082a0eafbb79e102ffc681bc11/python/cpython/issues/116576 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc87196248d7f2b92d3010bee3035200a916e5082a0eafbb79e102ffc681bc11/python/cpython/issues/116576 |
| og:image:alt | Bug report Bug description: It's supposed to measure sort speed for different kinds of data, from best to worst case. But currently it shows about the same speed for all kinds, because the same lis... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pochmann3 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4fa1799b6a53c2d30c950d74230781bef9e7f61138c72c7727e4b83f0743752b |
| 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 | 41f276818bd204c4a30a0281fb3c576298d9474c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width