Answer the question
In order to leave comments, you need to log in
Does multithreading make sense in Python?
The Python articles on multithreading ( Example 1 and Example 2 ) mention that due to the limitations of the GIL (Global Interpreter Lock), running a multithreaded application will at best take the same amount of time as a single-threaded application, but actually longer. In that case, does multithreading make any sense in Python?
Answer the question
In order to leave comments, you need to log in
Of course it does :)
The GIL only interferes with the parallel use of the processor within the same process. You can use threads for long IO operations, you can use processes for operations on the CPU, they are not subject to GIL :)
It strongly depends on the task at hand.
For tasks like the user interface - one thread is enough, to speed up the processing of a stream of independent requests with a high latency - you can safely write multi-threaded solutions, and even taking into account the GIL there will be a big gain.
But for mathematical calculations of large data arrays - here I would like to disable GIL, because splitting a task into prodprocesses sometimes eats up all the benefits of using many core processors with its overhead resources.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question