[Python-ideas] Should iscoroutine and iscoroutinefunction be in builtins?

Nathaniel Smith njs at pobox.com
Sun Jul 2 23:35:34 EDT 2017


On Sun, Jul 2, 2017 at 8:18 PM, Alex Walters <tritium-list at sdamon.com> wrote:
> Before async/await it made sense that iscoroutine and iscoroutinefunction
> live in asyncio.  But now that coroutines are a built in type, supported by
> its own syntax, wouldn't it make sense to make those functions builtins?

Technically "builtins" refers to the functions like "len" that are
automatically available without having to be imported; this is a
pretty select set of functions, and iscoroutine{,function} are
unlikely to qualify.

However, there are now versions of iscoroutine and iscoroutinefunction
that live in the "inspect" module, and which do what you'd expect for
native built-in coroutines. The versions in the asyncio module are a
little different; they also recognize various objects that asyncio
wants to treat like coroutines, like generators decorated with
@asyncio.coroutine.

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-ideas mailing list