Title: gh-162350: Add AC vectorcall for itertools by tanloong · Pull Request #162590 · python/cpython · GitHub
Open Graph Title: gh-162350: Add AC vectorcall for itertools by tanloong · Pull Request #162590 · python/cpython
X Title: gh-162350: Add AC vectorcall for itertools by tanloong · Pull Request #162590 · python/cpython
Description: Add @vectorcall to existing AC. Replace hand-written constructors with AC + vectorcall. product(..., repeat=1, bad='a') now raises got an unexpected keyword argument 'bad' instead of takes at most 1 keyword argument (2 given). zip_longest(..., bad='a') now raises TypeError: zip_longest() got an unexpected keyword argument 'bad' instead of TypeError: zip_longest() got an unexpected keyword argument. Other error text for bad argument is unchanged. Benchmark: +-------------------------------------+--------+----------------------+ | Benchmark | main | patch | +=====================================+========+======================+ | batched(x, 2) | 171 ns | 143 ns: 1.20x faster | +-------------------------------------+--------+----------------------+ | pairwise(x) | 174 ns | 145 ns: 1.20x faster | +-------------------------------------+--------+----------------------+ | groupby(x) | 173 ns | 131 ns: 1.32x faster | +-------------------------------------+--------+----------------------+ | cycle(x) | 171 ns | 143 ns: 1.20x faster | +-------------------------------------+--------+----------------------+ | dropwhile(pred, x) | 162 ns | 127 ns: 1.28x faster | +-------------------------------------+--------+----------------------+ | takewhile(pred, x) | 162 ns | 128 ns: 1.27x faster | +-------------------------------------+--------+----------------------+ | islice(x, 2) | 192 ns | 144 ns: 1.33x faster | +-------------------------------------+--------+----------------------+ | starmap(pow, pairs) | 173 ns | 136 ns: 1.28x faster | +-------------------------------------+--------+----------------------+ | chain(x) | 159 ns | 146 ns: 1.09x faster | +-------------------------------------+--------+----------------------+ | product(x) | 195 ns | 163 ns: 1.20x faster | +-------------------------------------+--------+----------------------+ | combinations(x, 2) | 208 ns | 157 ns: 1.32x faster | +-------------------------------------+--------+----------------------+ | combinations_with_replacement(x, 2) | 201 ns | 160 ns: 1.26x faster | +-------------------------------------+--------+----------------------+ | permutations(x) | 199 ns | 156 ns: 1.27x faster | +-------------------------------------+--------+----------------------+ | accumulate(x) | 169 ns | 134 ns: 1.26x faster | +-------------------------------------+--------+----------------------+ | compress(x, selectors) | 172 ns | 143 ns: 1.20x faster | +-------------------------------------+--------+----------------------+ | filterfalse(pred, x) | 159 ns | 125 ns: 1.27x faster | +-------------------------------------+--------+----------------------+ | count() | 133 ns | 116 ns: 1.15x faster | +-------------------------------------+--------+----------------------+ | repeat(1) | 172 ns | 111 ns: 1.54x faster | +-------------------------------------+--------+----------------------+ | zip_longest(x) | 215 ns | 169 ns: 1.27x faster | +-------------------------------------+--------+----------------------+ | Geometric mean | (ref) | 1.24x faster | +-------------------------------------+--------+----------------------+ Details import pyperf SETUP = """ import itertools x = [1, 2, 3] pred = lambda v: False pairs = [(2, 3)] selectors = [1, 0, 1] """ CASES = [ ('batched(x, 2)', 'itertools.batched(x, 2)'), ('pairwise(x)', 'itertools.pairwise(x)'), ('groupby(x)', 'itertools.groupby(x)'), # _grouper is internal; exercised through groupby() # teedataobject is internal; exercised through tee() # _tee is internal; exercised through tee() ('tee(x, 2)', 'itertools.tee(x, 2)'), ('cycle(x)', 'itertools.cycle(x)'), ('dropwhile(pred, x)', 'itertools.dropwhile(pred, x)'), ('takewhile(pred, x)', 'itertools.takewhile(pred, x)'), ('islice(x, 2)', 'itertools.islice(x, 2)'), ('starmap(pow, pairs)', 'itertools.starmap(pow, pairs)'), ('chain(x)', 'itertools.chain(x)'), ('product(x)', 'itertools.product(x)'), ('combinations(x, 2)', 'itertools.combinations(x, 2)'), ('combinations_with_replacement(x, 2)', 'itertools.combinations_with_replacement(x, 2)'), ('permutations(x)', 'itertools.permutations(x)'), ('accumulate(x)', 'itertools.accumulate(x)'), ('compress(x, selectors)', 'itertools.compress(x, selectors)'), ('filterfalse(pred, x)', 'itertools.filterfalse(pred, x)'), ('count()', 'itertools.count()'), ('repeat(1)', 'itertools.repeat(1)'), ('zip_longest(x)', 'itertools.zip_longest(x)') ] runner = pyperf.Runner() for name, stmt in CASES: runner.timeit(name, stmt=stmt, setup=SETUP) Issue: gh-162350
Open Graph Description: Add @vectorcall to existing AC. Replace hand-written constructors with AC + vectorcall. product(..., repeat=1, bad='a') now raises got an unexpected keyword argument 'bad' instead o...
X Description: Add @vectorcall to existing AC. Replace hand-written constructors with AC + vectorcall. product(..., repeat=1, bad='a') now raises got an unexpected keyword argument 'bad&am...
Opengraph URL: https://github.com/python/cpython/pull/162590
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:950b8e02-ad81-ece2-7cf5-e264d1ebbd6e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | EB92:0DF6:12040D9:17EC587:6B0659D6 |
| html-safe-nonce | 8f00c37c933d4170b69735ff94cbc6df8045bfe23e83f634ee7e65c8e66373f2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjkyOjBERjY6MTIwNDBEOToxN0VDNTg3OjZCMDY1OUQ2IiwidmlzaXRvcl9pZCI6Ijc3NjQzNTk3NDY4NDQ3NzY5MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3e660f12d8ca7cda9da7b5278bc175030a62f6eed65fb742a83e04ae3e2975c1 |
| hovercard-subject-tag | pull_request:5480932180 |
| 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/162590/files |
| twitter:image | https://avatars.githubusercontent.com/u/71320000?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/71320000?s=400&v=4 |
| og:image:alt | Add @vectorcall to existing AC. Replace hand-written constructors with AC + vectorcall. product(..., repeat=1, bad='a') now raises got an unexpected keyword argument 'bad' instead o... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| 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 | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width