News for hackers. Stuff that matters.
Re:Async I/O for Python 3 by Locke1689 on Monday March 18, 2013 @04:24PM (#5396877)
As Guido mentions, @coroutine/yield from is very similar to C#'s async implementation (with some differences like type safety).

Since Guido has the barest of descriptions on how this works, you may find the C# async description useful. [1]

[1] http://msdn.microsoft.com/en-us/library/vstudio/hh191443.asp...

Re:Async I/O for Python 3 by johnsoft on Monday March 18, 2013 @07:41PM (#5397896)
Just to check if I'm understanding the presentation right, will the implementation involve compiler magic to turn this:

    @coroutine
    def getresp():
        s = socket()
        yield from loop.sock_connect(s, host, port)
        yield from loop.sock_sendall(s, b'xyzzy')
        data = yield from loop.sock_recv(s, 100)
        # ...
into this, similar to how C# does it? (let's pretend multi-line lambdas exist for a minute)

    def getresp():
        s = socket()
        loop.sock_connect(s, host, port).add_done_callback(lambda:
            loop.sock_sendall(s, b'xyzzy').add_done_callback(lambda:
                data = loop.sock_recv(s, 100).add_done_callback(lambda:
                    # ...
                )
            )
        )
Or will the `yield from`s bubble up all the way to the event loop and avoid the need for that?
Re:Async I/O for Python 3 by rdtsc on Tuesday March 19, 2013 @10:50AM (#5401198)
No magic there.

It is Eventlet and Gevent have that magic. Here is how that looks:

    def getresp():
        s = socket()
        s.connect((host,port))
        s.sendall(s,b'xyzzy')
        data = s.recv(s,100)

Compare that to any of the above. This is what is thrown away in favor of 'yield from' and @coroutine mess coupled with a completely parallel set of IO libraries.
Re:Async I/O for Python 3 by fzzzy on Tuesday March 19, 2013 @11:12AM (#5401342)
Well... There actually are a completely parallel set of IO libraries, it just happens that the interface can be identical to the existing blocking interfaces because of the greenlet stack slicing magic... So it only appears like there are not a completely parallel set of IO libraries.

But that's just a nitpick.

Re:Async I/O for Python 3 by rdtsc on Tuesday March 19, 2013 @01:43PM (#5402400)
> So it only appears like there are not a completely parallel set of IO libraries.

Right on. That's the great part -- both a simple way to program and re usability of libraries.

So far, I see library ecosystem fragmentation as the biggest issue of all and nobody seems to want to talk to it.

Academically all the yields and co-routines look so cool, in practice when you need 5 libraries to help with some task, and now you have to re-write them -- not so cool.

Re:Async I/O for Python 3 by ufo on Monday March 18, 2013 @11:53PM (#5398801)
I don't understand your question. From the implementation perspective Python doesn't rewrite things to continuation-passing-style but the end result should be the same.
Re:Async I/O for Python 3 by masklinn on Tuesday March 19, 2013 @06:31AM (#5399986)
Python does not do AST-rewriting at compilation, `yield` and `yield from` will handle stack reification for freezing and thawing of coroutines.

So chains of `yield`s and `yield from`s will bubble to the event loop.

Re:Async I/O for Python 3 by fzzzy on Tuesday March 19, 2013 @11:51AM (#5401595)
The yield from has to be explicitly bubbled all the way up the call chain to the main loop.