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.

Async I/O for Python 3

234 pointsby amirhhzabout 12 years ago

14 comments

rdtscabout 12 years ago
Sigh, another Async framework.<p>Yes it has nice features such can replace the reactor/hub thing. Has futures/promises/deferreds. That has all been done before in Twisted. Yields are cute and there was monocle, I wouldn't say it exactly took off : <a href="https://github.com/saucelabs/monocle" rel="nofollow">https://github.com/saucelabs/monocle</a><p>Twisted has inlineCallbacks that use yields as well. Just import Twisted into stdlib then and use that.<p>I am surprised that gevent was dismissed. Ok, there is also eventlet, if someone doesn't like gevent. Monkey patching is scary? Is it really _that_ scary? Most sane and portable IO code probably runs on that today. Why? Because there is no need to create a parallel world of libraries. Write a test does it pass? Does it handle your use case? I'll take not knowing if my green threads switch tasks and add another green thread lock, instead of doubling my code size with yields, callbacks and futures.<p>Let's talk about Twisted (sorry couldn't resist WAT video reference). I remember for years searching for parallel libraries to parse exotic protocols. Regular Python library is there, but no, can't use that, sorry. Gotta go find or write one that returns Deferreds. You add a single Twisted module in your code, good luck! -- it ripples all the way to the top through your API and you are doomed being locked into the Twisted world forever.<p>When gevent and eventlet came around it was like a breath of fresh air. This is what sane concurrent IO looks like in Python:<p><a href="http://eventlet.net/doc/examples.html" rel="nofollow">http://eventlet.net/doc/examples.html</a><p>My fear is that many will just say fuck it, I'll just use Go/Rust/Erlang for IO bound concurrent problems.<p>It is nice having a benevolent dictator, except when he goes a little crazy, then dictatorship doesn't sounds so much fun anymore.
评论 #5396266 未加载
评论 #5396265 未加载
评论 #5396545 未加载
评论 #5396721 未加载
评论 #5396945 未加载
评论 #5396568 未加载
评论 #5398078 未加载
评论 #5397214 未加载
评论 #5397333 未加载
评论 #5396856 未加载
评论 #5399360 未加载
评论 #5397537 未加载
CoffeeDregsabout 12 years ago
Perhaps the video makes more clear the rationale. E.g.<p><pre><code> Possible solution: "Standardizing gevent solves all its problems". One of the responses: "I like to write clean code from scratch". Another: "I really like clean interfaces". </code></pre> So I'd prefer that the BDFL work with the gevent folks to get it cleaned up and integrated while adjusting it to expose a "clean interface".<p>Perhaps the whole thing will make more sense once Guido provides more detail, but I'm underwhelmed and confused.
评论 #5397491 未加载
Locke1689about 12 years ago
As Guido mentions, @coroutine/yield from is very similar to C#'s async implementation (with some differences like type safety).<p>Since Guido has the barest of descriptions on how this works, you may find the C# async description useful. [1]<p>[1] <a href="http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/vstudio/hh191443.asp...</a>
评论 #5397896 未加载
pekkabout 12 years ago
Still puzzled why the primary inspiration for this is Twisted, which has some really ugly APIs.
评论 #5396031 未加载
评论 #5397466 未加载
评论 #5402132 未加载
ekimekimabout 12 years ago
A minor gripe (seperate from all my other gripes, which other people have already talked about):<p>"...run code in another thread - sometimes there is no alternative - eg. getaddrinfo(), database connections"<p>Just thought I'd mention that async-supporting DNS libs do exist (eg. gevent ships with C-ares), and in particular I've used async postgres database connections in both C and gevent. The code to gevent-ise psycopg2 connections is about 10 or 15 lines, iirc.
评论 #5399995 未加载
judahabout 12 years ago
&#62;&#62; "@coroutine / yield-from are very close to async / await in C# 5"<p>Cool to see languages learning from one another.
VeejayRampayabout 12 years ago
Reading that presentation, it seems that Python has way too many Asyncronous I/O libraries/frameworks on its hands (not to be inflammatory though, I see it as a chance).<p>I really wonder why that is not the case in Ruby. I mean there are some, but there's mostly confidential and there doesn't seem to be much interest around them. Especially not to the point that the project leader would take a stab at it.<p>Good on Python anyway, competition is good.
NDizzleabout 12 years ago
This powerpoint viewer would be much nicer to use if I could hit spacebar to skip down a page.
kzahelabout 12 years ago
Does anyone have a link to the video? Or for various PyCon 2013 videos in general?
评论 #5396084 未加载
opminionabout 12 years ago
Wait, Guido is proposing implementing INTERCAL'S COME FROM? (as yield from)?
评论 #5397974 未加载
评论 #5399384 未加载
nixarnabout 12 years ago
I think it's a great idea. I haven't tried Twisted and having to install some 3rd party component to get it working doesn't sound tempting, however being supported by default, does.
chris_mahanabout 12 years ago
dropbox.com is blocked at work. Anyone have an alternate link? I can see it on my cell phone, but generally pptx don't display well on 4 in screens.
timc3about 12 years ago
If Guido still worked at Google would this have been hosted on google docs and I would have been able to read it without Office?
评论 #5396030 未加载
评论 #5396047 未加载
评论 #5396750 未加载
评论 #5396782 未加载
benatkinabout 12 years ago
Why does Guido think this is general purpose enough to add to Python but that the scientific features to make it competitive with R aren't? Is he envious of node.js?
评论 #5396783 未加载
评论 #5399493 未加载
评论 #5396794 未加载
评论 #5397386 未加载