[python-tulip] Re: Cost of async call

2015-11-15 Thread Luca Sbardella

On Thursday, November 12, 2015 at 5:16:22 PM UTC, Imran Geriskovan wrote:
>
> What is the cost/overhead difference 
> between these calls? 
>
> await foo1() 
> foo2() 
>
> async def foo1(): 
> pass 
>
> def foo2(): 
>pass 
>
>
Double the time
https://gist.github.com/lsbardel/cbe62fa5218ee0252188
 


Re: [python-tulip] Re: Cost of async call

2015-11-15 Thread Imran Geriskovan
Using code below, I got ratios around 2.5-2.7.
Not so bad if carefully used.

I wonder how this figure would change in
upcoming releases. The reason I asked
the question, was to have some discussion
about the ingredients of it.

In short: Should we invest on it?

Regards,
Imran

now = datetime.now
async def main():

t1 = now()
for i in range(300):
foo1()
tot1 = now() - t1

t1 = now()
for i in range(300):
await foo2()
tot2 = now() - t1

print(tot2/tot1)

get_event_loop().run_until_complete(main())


On 11/15/15, Luca Sbardella  wrote:
>
> On Thursday, November 12, 2015 at 5:16:22 PM UTC, Imran Geriskovan wrote:
>>
>> What is the cost/overhead difference
>> between these calls?
>>
>> await foo1()
>> foo2()
>>
>> async def foo1():
>> pass
>>
>> def foo2():
>>pass
>>
>>
> Double the time
> https://gist.github.com/lsbardel/cbe62fa5218ee0252188
>
>