-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
GH-94108: Specialize for int & operation #94109
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
Is The number of We have discussed having some sort of double-dispatching mechanism and cache, to allow fast dispatching of binary operators without an explosion of instructions, but I can't find the original discussion. Maybe @brandtbucher can find it? The general idea is that we register a C function as an implementation of a binary operation for a specific pair of classes and operator. For example, we could register We'd probably keep the specific specializations for the most common operations, like |
Looking at the stats shows the |
I created this PR based on stats and 33% (largest failure) seemed significant to me but if you don't think this is worth it, I have no objection if you reject this :). |
I'm not rejecting this. I'm just not sure whether it is a good idea. I'm going to benchmark it first. |
Pyperformance shows a small speedup, but close to noise. |
Here you go: faster-cpython/ideas#162 |
Yeah, I made a pass at this a few months ago. Even adding in shift operations, I wasn't able to get above "1.00x faster". I'm skeptical of adding lots of additional code here for negligible gain. |
I'm inclined to reject this in favor of a table based approach: faster-cpython/ideas#162. The table based approach won't give as much of a speedup per specialization, but will allow many more specializations for fewer new opcodes. |
Benchmark:
./python -m pyperf timeit -s "a, b= 100, 200" "a & b"
Result: