-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-136157: Optimize asyncio.to_thread to avoid contextvars.copy_context() overhead for empty contexts #136159
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
base: main
Are you sure you want to change the base?
Conversation
…ad for empty contexts
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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.
Please provide some benchmarks.
Misc/NEWS.d/next/Library/2025-07-01-02-19-00.gh-issue-136157.jGs_zV.rst
Outdated
Show resolved
Hide resolved
if not ctx: | ||
callback = functools.partial(func, *args, **kwargs) | ||
else: | ||
callback = functools.partial(ctx.run, func, *args, **kwargs) |
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.
Hm, couldn't we alternatively add a fast path to Context.run
?
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.
I don't think so. Please see the issue for details.
Ah, oops, didn't look at the issue. It would be helpful to put them in the PR description as well. |
Uh oh!
There was an error while loading. Please reload this page.