[mypyc] Use native calls in singledispatch dispatch functions #10888
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for using native calls to registered implementations when generating dispatch functions for singledispatch functions, instead of always using non-native calls, which can significantly speed up singledispatch (see benchmark results below). We don't use native calls when the registered implementation is a decorated function, as using a native call would ignore any changes the decorator made to the function.
Benchmark Results
These are the results from running the sum_tree_singledispatch both with this change and on the current master (7808e82).
Current master
This PR
Test Plan
I added an irbuild test to make sure we are actually using native calls when there are no non-register decorators.