Should iscoroutine and iscoroutinefunction be in builtins?
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?
On Sun, Jul 02, 2017 at 11:18:04PM -0400, Alex Walters 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?
Generators and generator functions are built-in, supported by their own syntax, but 'isgenerator' and 'isgeneratorfunction' still live in the inspect module. So I think the answer to your question is no. -- Steve
On Sun, Jul 2, 2017 at 8:18 PM, Alex Walters <tritium-list@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
participants (3)
-
Alex Walters -
Nathaniel Smith -
Steven D'Aprano