George Fischoff wrote:
> So when the default is async, the user will get faster program, by default.

Chris Angelico wrote:
> Okay, well that's the problem. An async function won't yield the
values faster, and it will not allow two things to happen
simultaneously. It just allows I/O and other such operations to happen
asynchronously.

I think the OP might be somewhat conflating parallelism and concurrency. For anyone not entirely clear on the differences between the two, I would highly recommend the following video for an in-depth explanation: https://www.youtube.com/watch?v=cN_DpYBzKso. The usage of concurrent programming does not increase the speed of any given program by default, and is not suited to every situation.

On Mon, Sep 16, 2019 at 6:01 AM Chris Angelico <rosuav@gmail.com> wrote:
On Mon, Sep 16, 2019 at 7:13 PM George Fischhof <george@fischhof.hu> wrote:
>
> yes exactly I would like this.
>
> Regarding the waiting and frameworks:
>
> The solution should be independent from waiting and frameworks:
>
> Let's see what happens now (sync, not async)
>
> User has a generator, he wants values.
>
> Uses a for cycle to process all values from generator:
> Asks for first value - wait for the value to be computed
> Processes the value he got
> Asks for next value - wait for the value to be computed
> And processes again, and again
>
> The async version:
>
> User has a generator, he wants values, he created an async version, because he wants the values faster
>

Okay, well that's the problem. An async function won't yield the
values faster, and it will not allow two things to happen
simultaneously. It just allows I/O and other such operations to happen
asynchronously.

If you want the values faster, consider instead a second thread or
process and a queue; in place of the generator, just read from the
queue, which will block until you have something to read. Meanwhile,
your other thread/process is generating values and placing them on the
queue.

What you're asking for is not just a syntactic change - it's a
significant semantic change that introduces concurrency in ways that
async functions do not currently have. Basically you'd get all the
problems of threading, without the advantages of threading.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/LXAXTHPHYMUIKJIFVK4PN4OLB7LQGKZX/
Code of Conduct: http://python.org/psf/codeofconduct/