I know this is documented in PEP 492 but I'm struggling to understand why the inspect module has several test functions (iscoroutine, iscoroutinefunction, isawaitable) that only work for native coros. Comparatively the same functions in the asyncio module work for both native and generator based coros.
It was an interesting exercise for me to figure this out the hard way so it's safe to say there is peril in this distinction for at least one developer. Furthermore, the docs for both sets of functions don't elude to these subtle but important distinctions. Are there good reasons for this distinction going forward? Here are some surprising (to me) tests... Python 3.5.2 (default, Oct 14 2016, 12:54:53) [GCC 6.2.1 20160916 (Red Hat 6.2.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import inspect >>> import asyncio >>> inspect.iscoroutinefunction(asyncio.sleep) False >>> asyncio.iscoroutinefunction(asyncio.sleep) True >>> inspect.iscoroutine(asyncio.sleep(1)) False >>> asyncio.iscoroutine(asyncio.sleep(1)) True >>> inspect.isawaitable(asyncio.sleep(1)) 256 The last test is particularly interesting; At least it's truthy?