Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-128308: pass **kwargs to asyncio task_factory#128768
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-128308: pass **kwargs to asyncio task_factory#128768
Uh oh!
There was an error while loading.Please reload this page.
Conversation
5b7bf7b
to0da18e8
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
graingert commentedJan 20, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We were somewhat worried about the performance of creating a dict with kwargs and then unpacking it, but it seems pretty similar if not faster: It's a bit slower in the case where we have a name and a factory, which is a bit odd, but most of the time you'd be using a Loop subclass not a factory if you cared about this level of performance. importpyperfrunner=pyperf.Runner()runner.timeit(name="create a task with a name",stmt="loop.create_task(coro(), name='hello')",setup=["import asyncio; loop = asyncio.EventLoop()","async def coro(): pass"],teardown="loop.call_soon(loop.stop); loop.run_forever(); loop.close()",)runner.timeit(name="create a task without a name",stmt="loop.create_task(coro())",setup=["import asyncio; loop = asyncio.EventLoop()","async def coro(): pass"],teardown="loop.call_soon(loop.stop); loop.run_forever(); loop.close()",)runner.timeit(name="create a task with a name and factory",stmt="loop.create_task(coro(), name='hello')",setup=["import asyncio; loop = asyncio.EventLoop()","def task_factory(loop, coro, **kwargs): return asyncio.Task(coro, loop=loop, **kwargs)","loop.set_task_factory(task_factory)","async def coro(): pass", ],teardown="loop.call_soon(loop.stop); loop.run_forever(); loop.close()",)runner.timeit(name="create a task without a name, with a factory",stmt="loop.create_task(coro())",setup=["import asyncio; loop = asyncio.EventLoop()","def task_factory(loop, coro, **kwargs): return asyncio.Task(coro, loop=loop, **kwargs)","loop.set_task_factory(task_factory)","async def coro(): pass", ],teardown="loop.call_soon(loop.stop); loop.run_forever(); loop.close()",) before:6f167d7
after:539d2e9
|
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Uh oh!
There was an error while loading.Please reload this page.
38a9956
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Thanks@graingert for the PR, and@kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry,@graingert and@kumaraditya303, I could not cleanly backport this to
|
GH-130084 is a backport of this pull request to the3.13 branch. |
…onGH-128768)(cherry picked from commit38a9956)Co-authored-by: Thomas Grainger <tagrain@gmail.com>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
…#130084)* [3.13]gh-128308: pass `**kwargs` to asyncio task_factory (GH-128768)(cherry picked from commit38a9956)Co-authored-by: Thomas Grainger <tagrain@gmail.com>Co-authored-by: Kumar Aditya <kumaraditya@python.org>---------Co-authored-by: Thomas Grainger <tagrain@gmail.com>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
johng commentedApr 29, 2025
why did we break the API spec in a patch release? This caused a sudden breakage for us |
…ry (pythonGH-128768) (python#130084)"This reverts commit7b0543e.
Uh oh!
There was an error while loading.Please reload this page.