TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Reasons for Python async/await

135 pointsby hittarukiabout 10 years ago

5 comments

avolcanoabout 10 years ago
For context on this, check out PEP 492: <a href="https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0492&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.python.org&#x2F;dev&#x2F;peps&#x2F;pep-0492&#x2F;</a><p>It&#x27;s a really exciting proposal. AFAIK, it&#x27;d make Python 3 the first mainstream imperative scripting language to have these async&#x2F;await concepts built-in (there is a similar proposal for JavaScript&#x2F;ES7 built on top of generators and promises[1]). While I&#x27;ve commented before about how asyncio is still a bit more nascent than I&#x27;d like, I&#x27;m really excited to see where the community takes it.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;lukehoban&#x2F;ecmascript-asyncawait" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lukehoban&#x2F;ecmascript-asyncawait</a>
评论 #9579249 未加载
评论 #9578865 未加载
评论 #9579139 未加载
评论 #9578674 未加载
评论 #9580969 未加载
评论 #9581460 未加载
评论 #9579699 未加载
toshabout 10 years ago
Related: <a href="http:&#x2F;&#x2F;queue.acm.org&#x2F;detail.cfm?ref=rss&amp;id=2747873" rel="nofollow">http:&#x2F;&#x2F;queue.acm.org&#x2F;detail.cfm?ref=rss&amp;id=2747873</a><p>This is the ACM Queue paper about async&#x2F;await in Dart (iirc according to Erik Meijer the cleanest implementation of the concept so far).
cbsmithabout 10 years ago
The problem I have with async with is that you&#x27;ve already got issues with the syntax for &quot;with&quot; context managers and generators.<p><pre><code> def my_generator(): with something() as bar: for x in baz(): yield bar(x) # context manager will call bar.__exit__() before the second time through this loop. </code></pre> It&#x27;d make a LOT more sense to just make &quot;with&quot; understand when it is in a continuation and only invoke __exit__() when the continuation is being destroyed.
评论 #9580701 未加载
评论 #9581674 未加载
mherrmannabout 10 years ago
It seems to me like this is a feature that will only be used by 1% of Python programmers. I&#x27;m lacking a lot of context but personally I&#x27;d much prefer it if Guido spent his time fixing the Python 2&#x2F;3 conundrum. And even though these proposed changes are Python 3 only, the fact that only so few people will use them doesn&#x27;t do much in that regard.
评论 #9582293 未加载
thristianabout 10 years ago
The nice thing about Python generator functions was that they didn&#x27;t need a lot of syntax - if a function contains the &quot;yield&quot; keyword, it&#x27;s a generator, otherwise it&#x27;s not.<p>Given how closely tied generators are with async&#x2F;await, why do we need &quot;async def&quot;? Isn&#x27;t the presence of &quot;await&quot; or &quot;async for&quot; or &quot;async with&quot; enough to mark a function as asynchronous?
评论 #9581884 未加载
评论 #9580241 未加载