On Wed, Nov 30, 2016 at 12:53 AM, Marko Rauhamaa <ma...@pacujo.net> wrote:
> I have a couple of points to make with my question:
> * We are seeing the reduplication of a large subset of Python's
> facilities. I really wonder if the coroutine fad is worth the price.
I don't think there's any technical reason why functions like zip
can't support both synchronous and asynchronous iterators. For
_zip = __builtins__.zip
_azip = (some asynchronous zip implementation)
def __init__(self, *args):
self._args = args
Now I can do "for x, y in zip(a, b)" or "async for x, y in
zip(async_a, async_b)" and either will work as expected. Of course, if
you use the wrong construct then you'll probably get an error since
the underlying iterators don't support the protocol. But it keeps the
builtin namespace simple and clean.