-
Notifications
You must be signed in to change notification settings - Fork 213
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
Improve sync.py typing and utilities performance #390
Conversation
* Make sure `sync_to_async`/`async_to_sync` keeps the original function typing signature * Define iscoroutinefunction/markcoroutinefunction at import time instead of an if/else in runtime. This improves the performance of those function calls by almost 300%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look reasonable, but you will need to please the mypy in the CI to get this in!
@andrewgodwin thanks for the review. Just solved all the issues to please mypy :) |
Unfortunately not for 3.9 and below, it looks like - the problem with ParamSpec is it's relatively new, and you'll need a way of keeping things backward-compatible somehow. I don't care much about 3.7 as it's about to be EOL, but 3.8 and 3.9 do still matter. (Apologies I can't tell our CI to run for you on every commit!) |
Oh, sorry about that. The code at I only have python 3.11 in my local dev environment, so I'll only know for older versions once the CI gets to run
Np :) Hopefully everything should be fine now |
Still something awry it looks like. You should be able to run the full set of python versions tests locally with |
@andrewgodwin I was being lazy to install all required python versions =P. Just did that, ran tox and was able to really fix everything now. Sorry about that! |
Yup, all looks good now! Thanks, I appreciate you taking the time to go through all those revisions! |
Make sure
sync_to_async
/async_to_sync
keeps the original function typing signatureDefine iscoroutinefunction/markcoroutinefunction at import time instead of an if/else in runtime.
The current implementation:
Versus this PR
This is a performance improvement of almost 300%.