-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-45508: Specialize INPLACE_ADD #29024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🤖 New build scheduled with the buildbot fleet by @sweeneyde for commit 62c1d38 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
The s390x RHEL7 LTO PR failure is https://bugs.python.org/issue45484 |
You can remove |
Any performance numbers or specialization stats for this? |
Maybe I should read the first comment 🙂 |
I'd like to hold off merging this until we have a better way to handle classes like |
I merged with main and ran some microbenchmarks, and it seems Microbenchmark program: from pyperf import Runner
runner = Runner()
runner.timeit("int+=int",
setup="from itertools import repeat",
stmt="x = 0\n"
"for y in repeat(1, 10_000):\n"
" x += y; x += y; x += y; x += y; x += y"
)
runner.timeit("float+=float",
setup="from itertools import repeat",
stmt="x = 0.0\n"
"for y in repeat(1.0, 10_000):\n"
" x += y; x += y; x += y; x += y; x += y"
)
runner.timeit("str+=str",
setup="from itertools import repeat",
stmt="for y in repeat('a', 10_000):\n"
" x = ''; x += y; x += y; x += y; x += y; x += y"
)
runner.timeit("list[0]+=str",
setup="from itertools import repeat",
stmt="x = [None]\n"
"for y in repeat('a', 10_000):\n"
" x[0] = ''; x[0] += y; x[0] += y; x[0] += y; x[0] += y; x[0] += y"
)
runner.timeit("float+=int",
setup="from itertools import repeat",
stmt="x = 0.0\n"
"for y in repeat(1, 10_000):\n"
" x += y; x += y; x += y; x += y; x += y"
)
runner.timeit("decimal+=decimal",
setup="from itertools import repeat; from decimal import Decimal as D",
stmt="x = D(0)\n"
"for y in repeat(D(1), 10_000):\n"
" x += y; x += y; x += y; x += y; x += y"
)
runner.timeit("list[0]+=1",
setup="from itertools import repeat; from collections import defaultdict",
stmt="dd = [0]\n"
"for y in repeat(1, 10_000):\n"
" dd[0] += y; dd[0] += y; dd[0] += y; dd[0] += y; dd[0] += y",
)
runner.timeit("defaultdict(int)[0]+=1",
setup="from itertools import repeat; from collections import defaultdict",
stmt="dd = defaultdict(int)\n"
"for y in repeat(1, 10_000):\n"
" dd[0] += y; dd[0] += y; dd[0] += y; dd[0] += y; dd[0] += y",
) Results from PGO on MSVC:
Results from PGO on GCC (WSL):
|
Once #29482 is merged this will need to reworked for the Nth (and hopefully last) time. Sorry about that. |
I think PR 29482 will just make this obsolete -- it manages to re-use
|
Pyperformance/Specialization results: https://gist.github.com/sweeneyde/41a76356e875e2a98d16ce5410ab41c0
https://bugs.python.org/issue45508