You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncio.Task now uses asyncio.iscoroutine() to give a comprehensible error if a user creates a Task for a non-awaitable type.
The problem is that iscoroutine() is quite expensive for non-native coroutines (like the ones compiled with Cython), as it uses isinstance(obj, collections.abc.Coroutine) call. This makes 'loop.create_task(cython_coroutine)' 20% slower than 'loop.create_task(python_coroutine)'.
The PR adds a positive type cache to the iscoroutine() function and to the asyncio.Task C implementation. Both caches make 'loop.create_task()' equally fast for all kinds of coroutines.
1st1
changed the title
Optimize asyncio.iscoroutine() for non-native coroutines
Optimize asyncio.iscoroutine() and loop.create_task() for non-native coroutines
Dec 18, 2017
New changeset 0f47fa2 by Yury Selivanov (Andrew Svetlov) in branch 'master': bpo-32357: Use PySet_GET_SIZE macro in _is_coroutine() from _asynciomodule.c (bpo-4990) 0f47fa2
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: