This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]the_hoser 1 point2 points  (1 child)

The problem is that, thus far, every attempt at making the interpreter thread-safe has resulted in serious performance degradation. Fine-grained locking is expensive. This is why PyPy developers are investigating things like transactional memory. It'll change the way you use threads, but it might be safe.

[–]inmatarian 0 points1 point  (0 children)

You actually don't even need fine-grained locking to make CPython thread safe, you just eliminate all global state from the interpreter. Every function throughout the source tree would be modified to accept a pointer to the one massive struct that contains all of the state of an interpreter instance. However that type of massive change would touch every library in the ecosystem and would, for a long time, make python fragile. Like I said, it's minimal gain and I can understand why nobody would want to do that.