简体   繁体   中英

Python Shell High CPU Usage

I have Python 3.4.3 installed on an older laptop (Pentium 4) with Windows XP.

It seems that half the time when the Python shell is open, the CPU usage goes up to 12-13%.

It is the Python shell itself, not any Python script it may have launched, and not the IDLE text editor.

I have yet to figure out the pattern when it goes up and when it does not. CPU usage actually goes to zero when I begin to debug a tkinter based script.

The shell window is opened by clicking on IDLE shortcut, if it makes any difference.

I have resorted to closing the shell until I need it, while I am working in IDLE editor.

Any idea why this happens and can this be remedied?

IDLE normally runs in two processes: one to run the graphical user interface, one to run your code. The processes currently communicate through a socket. Each process polls the socket for input 20 times a second. The user process also calls tk update in case the use is using tkinter but is not running mainloop.

I have a 6-core Pentium with gigabytes of memory and SSD main drive running 64-bit Win10. I currently have 5 IDLE shells running and 5 corresponding user processes: installed 2.7, 3.4, 3.5, 3.6, and development build of 3.6. Task Manager mostly shows each at 0%. One occasionally bumps up to .7%. This would be a much higher % on a single core machine. This seems to happen more often with the 3.4 IDLE.

I can only speculate that some combination of less memory, slower memory, less CPU cache space, much slower swap to disk, old single-core laptop chip with fewer instructions, and older OS with fewer system calls results in the difference.

Does your laptop have its maximum memory?

How often when using IDLE is the 12% an actual problem? (I guess that partly depend on time on battery versus power cord.)

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.

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