I’ve used Python to write a piece of code that can be very time consuming(contains a lot of recursions). I was testing the code’s runtime, and I noticed no matter how complicated the code becomes, Python never consumes the full computing power of my CPU. I’m running Python on Windows7 with Intel Dual Core, and Python never uses more than 1 CPU. Basically one CPU is running while the other one is on idle.
Can someone explain a bit of what’s happening in the background? Thanks in advance!
Your script is running in a single process, so runs on a single processor. The Windows scheduler will probably move it from one core to another quite frequently, but it can’t run a single process in more than one place at a time.
If you want to use more of your CPU’s grunt, you need to figure out how to split your workload so you can run multiple instances of your code in multiple processes.