[Python-ideas] Fwd: [asyncio] Suggestion for a major PEP
chbailly at gmail.com
Sun Dec 16 13:18:45 EST 2018
I thought I had sent this mail to everybody, so here was my answer to
---------- Forwarded message ---------
From: Christophe Bailly <chbailly at gmail.com>
Date: Sun, 16 Dec 2018 at 13:56
Subject: Re: [Python-ideas] [asyncio] Suggestion for a major PEP
To: Nathaniel Smith <njs at pobox.com>
After reading many papers, I understand that it is not as simple as I could
imagine in my first thought.
Sorry about that, I have learned something. Explicit vs implicit
asynchronism is a complex topic.
On Sun, 16 Dec 2018 at 10:16, Nathaniel Smith <njs at pobox.com> wrote:
> If you want this style of concurrency, you don't need to write a PEP,
> just 'pip install gevent' :-)
> But unfortunately you're years too late to argue for making asyncio
> work this way. This was discussed extensively at the time, and the
> decision to use special syntax was made intentionally, and after
> studying existing systems like gevent that made the other choice.
> This section of the trio docs explain why explicit async/await syntax
> makes life easier for developers:
> It's also awkward but very doable to support both sync and async mode
> with a single code base: https://github.com/python-trio/unasync/
> In fact, when doing this, the async/await syntax isn't really the hard
> part – the hard part is that different libraries have very different
> networking APIs. E.g., the stdlib socket API and the stdlib asyncio
> API are totally different.
> On Sun, Dec 16, 2018 at 12:21 AM Christophe Bailly <chbailly at gmail.com>
> > Hello,
> > I copy paste the main idea from an article I have written:
> > contextual async
> > "
> > Imagine you have some code written for monothread. And you want to
> include your code in a multithread environment. Do you need to adapt all
> your code which is what you do when you want to migrate to async code ? The
> answer is no.
> > Functionnally these constraints are not justified neither technically
> > Do we have the tools to do this ? Yes because thanks to boost::context
> we can switch context between tasks. When a task suspends, it just calls a
> function (the event loop or reactor) to potentially switch to another task.
> Just like threads switch contexts…
> > Async/Await logic has introduced a symetric relation wich introduces
> unnecessary contraints. We should just the same logic as thread logic.
> > "
> > Read the examples in the article I have developped a prototype in C++
> and everything works perfectly.
> > My opinion is that sooner or later, it will have to switch to this logic
> because chaining async/aswait is a huge contraints and does not make sense
> in my opinion.
> > Maybe I am missing something,
> > Feel free to give me your feedback.
> > Regards,
> > Chris
> > _______________________________________________
> > Python-ideas mailing list
> > Python-ideas at python.org
> > https://mail.python.org/mailman/listinfo/python-ideas
> > Code of Conduct: http://python.org/psf/codeofconduct/
> Nathaniel J. Smith -- https://vorpus.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas