News for hackers. Stuff that matters.
Re:Python vs Ruby, slightly more in-depth by dkersten on Friday August 07, 2009 @11:14AM (#747695)
Sorry, 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

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. """

There are no comments on this comment yet.