|
|
|
|
|
by exDM69
4858 days ago
|
|
> Generally, you should only use threads if the following is true: - Sharing memory between threads is not an issue. Here's the problem. Threads are really useful only if you can share memory between threads. If you can't share memory, you're usually better off using many processes. Threads in Python (ie. CPython) can still be useful for I/O multiplexing or executing native code in background worker threads via FFI and releasing the GIL while doing so. For I/O multiplexing, there are better options than Python threads (select/poll/kqueue/epoll system calls and frameworks like twisted that use them). In most applications, threads probably should not be used in CPython/CRuby code as they provide little performance gain compared to the complexity and overhead they add. |
|