On 2015-05-07 1:42 PM, Guido van Rossum wrote: > On Tue, May 5, 2015 at 3:36 PM, Rajiv Kumar <rajiv.kumar at gmail.com> wrote: > >> I wrote a little example[1] that has a bare-bones implementation of Go >> style channels via a custom event loop. I used it to translate the prime >> sieve example from Go[2] almost directly to Python. The code uses "message >> = await channel.receive()" to mimic Go's "message <- channel". Instead of >> using "go func()" to fire off a goroutine, I add the PEP492 coroutine to my >> simple event loop. >> > Cool example! > > It's not an efficient implementation - really just a proof of concept that >> you can use async/await in your own code without any reference to asyncio. >> I ended up writing it as I was thinking about how PEP 342 style coroutines >> might look like in an async/await world. >> >> In the course of writing this, I did find that it would be useful to have >> the PEP document how event loops should advance the coroutines (via >> .send(None) for example). It would also be helpful to have the semantics of >> how await interacts with different kinds of awaitables documented. I had to >> play with Yury's implementation to see what it does if the __await__ just >> returns iter([1,2,3]) for example. >> > I've found this too. :-) Yury, perhaps you could show a brief example in > the PEP of how to "drive" a coroutine from e.g. main()? OK, will do! Thanks, Yury
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4