Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread 王珺
I think this is possible if I understand what happens under the hood. I wonder how event loop and async io functions such as asyncio.open_connection cooperate to do async io in one thread. Maybe it exploits low-level details and is OS or even device specific. I think I should take a look at the sou

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Gregory Ewing
王珺 wrote: Suppose io_operation() takes 3 seconds, then how can I write something like future = io_operation() print('Start') time.sleep(1) print('Something') time.sleep(2) print(future.result()) that print 'Start' immediately and the result of io_operation() 3 seconds later. Yes, Python can d

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Ian Kelly
On Wed, Feb 24, 2016 at 9:13 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: >>> Tem Pl : Is there something wrong with this implementation? >>> >>> It's a "fork bomb". >> >> Isn't that the point of the benchmark? > > I don't quite see the

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Marko Rauhamaa
Ian Kelly : > On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: >> Tem Pl : >>> Is there something wrong with this implementation? >> >> It's a "fork bomb". > > Isn't that the point of the benchmark? I don't quite see the point of the program as it doesn't resemble anything I'd ever have an

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Ian Kelly
On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: > Tem Pl : > >> Here are some concurrency benchmarks for python vs other languages. >> >> https://github.com/atemerev/skynet/pull/53 >> >> Is there something wrong with this implementation? > > It's a "fork bomb". Isn't that the point of the

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Marko Rauhamaa
Tem Pl : > Here are some concurrency benchmarks for python vs other languages. > > https://github.com/atemerev/skynet/pull/53 > > Is there something wrong with this implementation? It's a "fork bomb". Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Tem Pl
Here are some concurrency benchmarks for python vs other languages. https://github.com/atemerev/skynet/pull/53 Is there something wrong with this implementation? "Hope I suck at coroutines, because the results are abysmal. I get around 63s on my i5 MacBook Air Early 2015. For reference, the go

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread 王珺
It seems an event loop is required for all async programs in python, but sometimes I need only lazy i/o. Is it possible with asyncio? Suppose io_operation() takes 3 seconds, then how can I write something like future = io_operation() print('Start') time.sleep(1) print('Something') time.sleep(2)

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Victor Stinner
See also Doug Hellmann article on asyncio, from its serie of "Python 3 Module of the Week" articles: https://pymotw.com/3/asyncio/index.html Victor 2016-02-23 22:25 GMT+01:00 Joao S. O. Bueno : > Today I also stumbled on this helpful "essay" from Brett Cannon about > the same subject > > http://w

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Paul Moore
On 24 February 2016 at 02:37, Terry Reedy wrote: > > In this essay, Brett says that asyncio added an event loop to Python. It > did, but it was the second. The tk event loop was added about 20 years ago > with tkinter. One of the things I would love to see (but don't have the time to work on) is

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Joao S. O. Bueno
Today I also stumbled on this helpful "essay" from Brett Cannon about the same subject http://www.snarky.ca/how-the-heck-does-async-await-work-in-python-3-5 On 23 February 2016 at 18:05, Sven R. Kunze wrote: > On 20.02.2016 07:53, Christian Gollwitzer wrote: > > If you have difficulties wit hthe