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, gvanrossum, methane, ned.deily, vstinner, yselivanov
Date 2016-11-03.18:29:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
loop.call_soon is the central function of asyncio.  Everything goes through it.

Current design of asyncio.loop.call_soon makes the following checks:

1. [debug mode] check that the loop is not closed
2. [debug mode] check that we are calling call_soon from the proper thread
3. [always] check that callback is not a coroutine or a coroutine function

Check #3 is very expensive, because it uses an 'isinstance' check.  Moreover, isinstance checks against an ABC, which makes the call even slower.

Attached patch makes check #3 optional and run only in debug mode.  This is a very safe patch to merge.

This makes asyncio another 17% (sic!) faster.  In fact it becomes as fast as curio for realistic streams benchmarks.
Date User Action Args
2016-11-03 18:29:01yselivanovsetrecipients: + yselivanov, gvanrossum, vstinner, ned.deily, asvetlov, methane
2016-11-03 18:29:01yselivanovsetmessageid: <>
2016-11-03 18:29:01yselivanovlinkissue28600 messages
2016-11-03 18:29:01yselivanovcreate