Skip to content

[mypyc] Use native calls to singledispatch functions (#10981) #110

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

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

sthagen
Copy link
Owner

@sthagen sthagen commented Aug 16, 2021

  • Wrap singledispatch callable class in glue function

mypyc doesn't have support for calling callable classes without going
through the python API, so instead of having to special case the
singledispatch callable class when we want to generate a native call to
it, we create a glue function that loads the callable class from the
globals dict and then makes a native call to that callable class's
call method.

  • Use native calls for singledispatch functions

Use a native call to the glue function that we generate for
singledispatch functions instead of calling those singledispatch
functions through the python API.

  • Add irbuild test for native calls to singledispatch functions

Add an irbuild test to make sure we use native calls to the glue
functions for singledispatch functions, and that the glue functions make
native calls to the call methods on the callable classes.

  • Fix irbuild test

Have you read the Contributing Guidelines?

(Once you have, delete this section. If you leave it in, your PR may be closed without action.)

Description

(Explain how this PR changes mypy.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

* Wrap singledispatch callable class in glue function

mypyc doesn't have support for calling callable classes without going
through the python API, so instead of having to special case the
singledispatch callable class when we want to generate a native call to
it, we create a glue function that loads the callable class from the
globals dict and then makes a native call to that callable class's
__call__ method.

* Use native calls for singledispatch functions

Use a native call to the glue function that we generate for
singledispatch functions instead of calling those singledispatch
functions through the python API.

* Add irbuild test for native calls to singledispatch functions

Add an irbuild test to make sure we use native calls to the glue
functions for singledispatch functions, and that the glue functions make
native calls to the __call__ methods on the callable classes.

* Fix irbuild test
@sthagen sthagen merged commit 5f1d03b into sthagen:master Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants