<span>The way I see it, the great thing about async/await as opposed to threading is that it is explicit about when execution will "take a break" from your function or resume into it. This is made clear and readable through the use of `await` keywords.</span><div><br></div><div>Your proposal unfortunately goes directly against this idea of explicitness. You won't know what function will need to be fed into an event loop or not. You won't know where your code is going to lose or gain control.<br><br><div class="gmail_quote"><div dir="ltr">On Sun, Oct 2, 2016, 14:26 Rene Nejsum <<a href="mailto:rene@stranden.com">rene@stranden.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Having followed Yury Selivanov <a href="http://yselivanov.ml" class="gmail_msg" target="_blank">yselivanov.ml</a> at <a href="http://gmail.com" class="gmail_msg" target="_blank">gmail.com</a> proposal to add async/await to Python (PEP 492 Coroutines with async and await syntax and (PEP 525 Asynchronous Generators) and and especially the discussion about PEP 530: Asynchronous Comprehensions I would like to add some concerns about the direction Python is taking on this.<br class="gmail_msg"><br class="gmail_msg">As Sven R. Kunze srkunze at <a href="http://mail.de" class="gmail_msg" target="_blank">mail.de</a> mentions the is a risk of having to double a lot of methods/functions to have an Async implementation. Just look at the mess in .NET when Microsoft introduced async/await in their library, a huge number of functions had to be implemented with a Async version of each member. Definitely not the DRY principle.<br class="gmail_msg"><br class="gmail_msg">While I think parallelism and concurrency are very important features in a language, I feel the direction Python is taking right now is getting to complicated, being difficult to understand and implement correct.<br class="gmail_msg"><br class="gmail_msg">I thought it might be worth to look at using async at a higher level. Instead of making methods, generators and lists async, why not make the object itself async? Meaning that the method call (message to object) is async<br class="gmail_msg"><br class="gmail_msg">Example:<br class="gmail_msg"><br class="gmail_msg">class SomeClass(object):<br class="gmail_msg"> def some_method(self):<br class="gmail_msg"> return 42<br class="gmail_msg"><br class="gmail_msg">o = async SomeClass() # Indicating that the user want’s an async version of the object<br class="gmail_msg">r = o.some_method() # Will implicit be a async/await “wrapped” method no matter impl.<br class="gmail_msg"># Here other code could execute, until the result (r) is referenced<br class="gmail_msg">print r<br class="gmail_msg"><br class="gmail_msg">I think above code is easier to implement, use and understand, while it handles some of the use cases handled by defining a lot of methods as async/await.<br class="gmail_msg"><br class="gmail_msg">I have made a small implementation called PYWORKS (<a href="https://github.com/pylots/pyworks" class="gmail_msg" target="_blank">https://github.com/pylots/pyworks</a>), somewhat based on the idea above. PYWORKS has been used in several real world implementation and seams to be fairly easy for developers to understand and use.<br class="gmail_msg"><br class="gmail_msg">br<br class="gmail_msg">/Rene<br class="gmail_msg"><br class="gmail_msg">PS. This is my first post to python-ideas, please be gentle :-)</div>_______________________________________________<br class="gmail_msg">
Python-ideas mailing list<br class="gmail_msg">
<a href="mailto:Python-ideas@python.org" class="gmail_msg" target="_blank">Python-ideas@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br class="gmail_msg">
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" class="gmail_msg" target="_blank">http://python.org/psf/codeofconduct/</a></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Yann Kaiser<div><div><a href="mailto:kaiser.yann@gmail.com">kaiser.yann@gmail.com</a></div><div><a href="mailto:yann.kaiser@efrei.net">yann.kaiser@efrei.net</a></div><div>+33 6 51 64 01 89</div></div><div><a href="https://github.com/epsy">https://github.com/epsy</a></div></div></div>