3 ms·
That's not strictly true. Take a look at http://plausible.org/nasal http://plausible.org/nasal for an example of an interpreter (mine) in the same broad space
by ajross 17y ago
That's not strictly true. Take a look at http://plausible.org/nasal http://plausible.org/nasal for an example of an interpreter (mine) in the same broad space as Python and Ruby, yet without a global lock for anything but garbage collection (fixable -- there's no reason in principle preventing a concurrent GC from being dropped in). In tests of CPU-bound code without excessive allocation, it scales to 4-way SMP without trouble.
- dkersten 17y agoSorry, I meant in Pythons case. Obviously theres plenty of virtual machines/interpreters/compilers which do not have a GIL and work perfectly fine. Here are some of the reasons Python uses a GIL: http://www.grouplens.org/node/244#comment-2493 http://www.grouplens.org/node/244#comment-2493 Pasted for convenience: """ Python has a GIL as opposed to fine-grained locking for several reasons: --- It is faster in the single-threaded case. --- It is faster in the multi-threaded case for i/o bound programs. --- It is faster in the multi-threaded case for cpu bound programs that do their compute-intensive work in C libraries. --- It makes C extensions easier to write: there will be no switch of Python threads except where you allow it to happen (i.e. between the Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS macros). --- It makes wrapping C libraries easier. You don't have to worry about thread-safety. If the library is not thread-safe, you simply keep the GIL locked while you call it. """