-1

As the title reads, my question is:

If a CPU core has two threads, how can let's say a loop in python send 50 requests at once if it's not a 25 core CPU?

  • A loop *can't* send 50 requests at once: it's a *repetition* of executing code. It does by definition send one after the other. – MisterMiyagi Oct 01 '21 at 15:03
  • There is a subtle distinction between "parallel" and "concurrent". Check out https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism – JonSG Oct 01 '21 at 15:44

1 Answers1

0

I remember my parallel computing programming course using MPI and while MPI was able to simulate the presence of several "processes" the degree of parallelism was limited by the number of processors in the parallel computing environment. Therefore, respect of your question, the answer is your Python loop is "simulating" the sending of 50 request at once because:

"Threads refer to the highest level of code executed by a processor, so with many threads, your CPU can handle several tasks at the same time. All CPUs have active threads, and every process performed on your computer has at least a single thread."

(https://whatsabyte.com/blog/processor-threads/)

Today's High Speed processors can "make us feel" that the computer is running several things at the same time while it is truly running them sequentially.

Jose Cabrera Zuniga
  • 2,348
  • 3
  • 31
  • 56
  • So you're saying that my 8-core CPU takes turns running my code but really fast so that it simulates the computing power of a more powerful unit? @Jose Cabrera Zuniga – slightlyconfused Oct 01 '21 at 14:48
  • basically yes... the maximum degree of parallelism using your 8 core cpu will be 8. If you try to use, for example, 16 processes "at the same time" then maximum 8 of them will run in parallel. – Jose Cabrera Zuniga Oct 01 '21 at 17:02