[英]Delay after final print statement before ending the program. Core dumped in c equivalent
There is a good amount of delay (~7-8s) after the final print statement before the program ends while running this code.在运行此代码时程序结束之前的最终打印语句之后存在大量延迟(约 7-8 秒)。
li = []
for i in range(100000000): # A very huge number
li.append(i)
print("Done.")
Pypy worked much faster and showed the expected behaviour. Pypy 工作得更快,并显示出预期的行为。 Why is this happening?
为什么会这样?
I cannot reproduce your results!我无法重现您的结果!
This was run on Google Colab CPU instance这是在 Google Colab CPU 实例上运行的
It is taking 00.000093
seconds for print statement and program to end!打印语句和程序结束需要
00.000093
秒!
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.