简体   繁体   English

在结束程序之前的最终打印语句之后延迟。 在 c 等效项中转储的核心

[英]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.

相关问题 Python 代码在打印语句期间/之后停止输出,但同一部分代码在作为自己的程序隔离时工作。 这是怎么回事? - Python code stops outputting during/after print statement, but the same part of code works when isolated as its own program. What's going on? 我想打印从 1 到 n 的数字,但在运行此代码后,出现“核心转储”错误 - i want to print number from 1 to n but after running this code, error "core dumped" occured 递归函数,最终打印语句 - Recursive function, final print statement 在循环外打印最终声明 - Print Final Statement Outside For Loop Spotify Best Before计划。 我究竟做错了什么? - Spotify Best Before program. What am I doing wrong? 程序在&#39;if&#39;执行事件后没有结束 - Program not ending after 'if' executes events 如何在多步骤map-reduce程序中一次运行最终的“打印”语句? - How to run a final 'print' statement once in a multi-step map-reduce program? 定时延迟或重定向后获取最终URL - Get final url after timed delay or redirect 在调用带有 tqdm 进度条的函数之前打印语句会导致在 tddm 之后打印打印语句 - Print statement just before calling a function with a tqdm progress bar results in the print statement being printed after tddm Python:如何在运行for语句后不仅输出最终值,还输出中间输出? - Python:How do I print not only the final value after running the for statement, but also the middle output?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM