There is a good amount of delay (~7-8s) after the final print statement before the program ends while running this code.
li = []
for i in range(100000000): # A very huge number
li.append(i)
print("Done.")
Pypy worked much faster and showed the expected behaviour. Why is this happening?
I cannot reproduce your results!
This was run on Google Colab CPU instance
It is taking 00.000093
seconds for print statement and program to end!
from datetime import datetime as dt
from tqdm import tqdm
start = dt.now()
li = []
for i in tqdm(range(100000000)): # A very huge number
li.append(i)
print('\n')
print('Time to run:',dt.now()-start)
start = dt.now()
print("Done.")
print('Time after run:',dt.now()-start)
100%|██████████| 100000000/100000000 [00:33<00:00, 3010464.83it/s]
Time to run: 0:00:34.386686
Done.
Time after run: 0:00:00.000093
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.