简体   繁体   English

命令行中的快速python脚本与在IDLE shell中启动

[英]speed python script on command line vs launched in IDLE shell

I noticed several times that a simple python script (with some straightforward algebraic computation in a loop) runs considerably faster (up to a factor 6) when launched on a shell command line as compared to a run via IDLE's shell. 我多次注意到,与通过IDLE的shell运行相比,在shell命令行上启动时,简单的python脚本(在循环中进行一些简单的代数计算)运行速度快得多(达到6倍)。 There is nothing fancy going on in the script. 脚本中没有任何幻想。 I only print a loop variable to visually follow progress in the loop. 我只打印一个循环变量以直观地跟踪循环的进度。

Surely just this print statement cannot be the reason for the speed loss in IDLE, or can it ? 当然,仅此打印语句不能成为IDLE速度下降的原因,还是可以吗?

Can someone explain me why this is ? 有人可以解释我为什么吗?

The Tkinter text widget is slow, and IDLE uses this to print text to screen. Tkinter文本小部件很慢,IDLE使用它来将文本打印到屏幕上。

See this question. 看到这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM