On Fri, Oct 23, 2020 at 6:19 AM Tin Tvrtković <tinches...@gmail.com> wrote:

> Hi,
>
> first of all, I'm a big fan of the changes being proposed here since in my
> code I prefer the 'union' style of logic over the OO style.
>
> I was curious, though, if there are any plans for the match operator to
> support async stuff. I'm interested in the problem of waiting on multiple
> asyncio tasks concurrently, and having a branch of code execute depending
> on the task.
>
> Currently this can be done by using asyncio.wait, looping over the done
> set and executing an if-else chain there, but this is quite tiresome. Go
> has a select statement (https://tour.golang.org/concurrency/5) that looks
> like this:
>
> select {
> case <-ch1:
>     fmt.Println("Received from ch1")
> case <-ch2:
>     fmt.Println("Received from ch2")
> }
>
> Speaking personally, this is a Go feature I miss a lot when writing
> asyncio code. The syntax is similar to what's being proposed here. Although
> it could be a separate thing added later, async match, I guess.
>

Hadn't seen this before. You could propose this as a follow-up for 3.11.
But aren't Go channels more like asyncio Queues? I guess we'd need way more
in terms of a worked-out example (using asyncio code, not Go code).
-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/2X5TX25QAGQJJFPGU5X7V6JC5ESIGJT7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to