Title: bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP by sweeneyde · Pull Request #32239 · python/cpython · GitHub
Open Graph Title: bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP by sweeneyde · Pull Request #32239 · python/cpython
X Title: bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP by sweeneyde · Pull Request #32239 · python/cpython
Description: Most code won't do y = L.append(x) or whatnot, so PRECALL_NO_KW_LIST_APPEND is almost always followed by POP_TOP. We can verify at specialization time. This saves a Py_INCREF(Py_None), a SET_TOP(Py_None), and POP_TOP's Py_DECREF(POP()); DISPATCH();. Some microbenchmarks: from pyperf import Runner, perf_counter def bench_append(loops, length): src = list(map(float, range(length))) arr = [] t0 = perf_counter() for i in range(loops): arr.clear() for x in src: arr.append(x) return perf_counter() - t0 def bench_append_less_gc(loops, length): src = list(map(float, range(length))) out = [None] * loops t0 = perf_counter() for i in range(loops): arr = [] for x in src: arr.append(x) out[i] = arr return perf_counter() - t0 runner = Runner() for n in [100, 1_000, 10_000, 100_000]: runner.bench_time_func(f"append {n}", bench_append, n, inner_loops=n) runner.bench_time_func(f"append-less-gc {n}", bench_append_less_gc, n, inner_loops=n) From GCC, --enable-optimizations, --with-lto: - append 100000: 14.9 ns +- 0.3 ns -> 13.3 ns +- 0.4 ns: 1.12x faster - append 10000: 15.1 ns +- 0.3 ns -> 13.6 ns +- 0.5 ns: 1.11x faster - append-less-gc 100000: 16.4 ns +- 0.5 ns -> 14.9 ns +- 0.4 ns: 1.10x faster - append 1000: 15.6 ns +- 0.3 ns -> 14.2 ns +- 0.3 ns: 1.09x faster - append 100: 18.9 ns +- 0.6 ns -> 17.3 ns +- 0.6 ns: 1.09x faster - append-less-gc 100: 27.4 ns +- 1.1 ns -> 25.2 ns +- 1.2 ns: 1.09x faster - append-less-gc 10000: 19.2 ns +- 0.3 ns -> 17.8 ns +- 0.2 ns: 1.08x faster - append-less-gc 1000: 22.0 ns +- 0.6 ns -> 20.8 ns +- 0.3 ns: 1.06x faster Geometric mean: 1.09x faster https://bugs.python.org/issue47009
Open Graph Description: Most code won't do y = L.append(x) or whatnot, so PRECALL_NO_KW_LIST_APPEND is almost always followed by POP_TOP. We can verify at specialization time. This saves a Py_INCREF(Py_None), a SET_TO...
X Description: Most code won't do y = L.append(x) or whatnot, so PRECALL_NO_KW_LIST_APPEND is almost always followed by POP_TOP. We can verify at specialization time. This saves a Py_INCREF(Py_None), a SE...
Opengraph URL: https://github.com/python/cpython/pull/32239
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6c68acca-38d2-ec9c-c8bd-7d994f738476 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C476:220088:158B86:1E1D7D:696A6C45 |
| html-safe-nonce | 5af8fb14db00aa5737a327b0e1cfc75c6d4b9dd04f7b3a50508700bd75f54f96 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDc2OjIyMDA4ODoxNThCODY6MUUxRDdEOjY5NkE2QzQ1IiwidmlzaXRvcl9pZCI6IjY5MDkzMjQzNDM1MzE1NTE0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 38814e1814cb49bad277846476c443bb98934bd07673464556040b1d10a21759 |
| hovercard-subject-tag | pull_request:897704861 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/32239/files |
| twitter:image | https://avatars.githubusercontent.com/u/36520290?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/36520290?s=400&v=4 |
| og:image:alt | Most code won't do y = L.append(x) or whatnot, so PRECALL_NO_KW_LIST_APPEND is almost always followed by POP_TOP. We can verify at specialization time. This saves a Py_INCREF(Py_None), a SET_TO... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width