5 ms·
It would be inefficient to share data structures or interpreter internal state across threads. This would lead to the poor performance you described with mutex
by morebetterer 11y ago
It would be inefficient to share data structures or interpreter internal state across threads. This would lead to the poor performance you described with mutex contention.
It is better to have an interpreter instance per thread, each having their own separate variable pool, and pass messages between the different interpreter instances. This model scales well with multicore systems and is faster than the multi-process equivalent.
It's also a simpler model to implement and maintain. Python's current multithreading model is too complicated from an implementation point of view.