4 ms·
You meant "other thread" rather than "other process", right? But that doesn't take much work at all -- just a mutable data structure as a global variable.
by da39a3ee 5y ago
You meant "other thread" rather than "other process", right? But that doesn't take much work at all -- just a mutable data structure as a global variable.
- Animats 5y ago"Other thread", yes. The point, though, is that basic optimizations, like hoisting some computation out of a loop, are off the table in Python, because the compiler can't be sure something won't mess with the innards of the loop at run time. Yes, you can do awful things involving creating an optimized loop, detecting at run time that someone broke it from the outside, and switching from compiled to interpreted mode. I think PyPy does stuff like that. It's a huge effort in the compiler and in the runtime to handle such cases. It's also part of why Python sucks at threading, with the Global Interpreter Lock. There's not enough separation between threads.
- da39a3ee 5y agoRuby has a GIL too, as far as I understand. Is the GIL in Ruby comparable to that in Python and present for similar reasons? If so, does that suggest that it's a genuine design constraint rather than a bad design decision? You don't say so explicitly, but your last sentence sounds like it's saying Python's GIL is due to bad design.