3 ms·
Python "threads" aren't real threads in the traditional sense because Python's Global Interpreter Lock (GIL) exists, and this means no more than one thread is e
by dkh 2y ago
Python "threads" aren't real threads in the traditional sense because Python's Global Interpreter Lock (GIL) exists, and this means no more than one thread is ever actually running in parallel. They are great for network IO since most IO is just spent waiting for stuff rather than computing anything, but you can't actually run CPU-heavy stuff on multiple Python threads and have the speed multiplier be equal to the number of thread workers. For this, you have to use process pools. (Though this is something that is in the process of finally being alleviated/fixed!)
- lyu07282 2y agoThis seems all a bit misleading to beginners, if you have numerical cpu-bound work in Python what you should be doing is vectorize it, not parallelize. https://www.geeksforgeeks.org/vectorized-operations-in-numpy/ https://www.geeksforgeeks.org/vectorized-operations-in-numpy...
- dkh 2y agoThe point is that the use-case here is one where there is far more IO-bound work than CPU-bound.
- deleted 2y ago[deleted]