This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients asvetlov, yselivanov
Date 2017-12-18.05:33:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513575220.77.0.213398074469.issue32357@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-18 05:33:40yselivanovsetrecipients: + yselivanov, asvetlov
2017-12-18 05:33:40yselivanovsetmessageid: <1513575220.77.0.213398074469.issue32357@psf.upfronthosting.co.za>
2017-12-18 05:33:40yselivanovlinkissue32357 messages
2017-12-18 05:33:40yselivanovcreate