From: "Adam P. Jenkins" Date: 2005-07-30T04:41:02+09:00 Subject: Re: Ruby and threads Yohanes Santoso wrote: > You can test whether current python implementation still use a global > interpreter lock or not by trying to span multiple threads, each doing > some CPU-intensive computation (e.g. repeatedly increasing the value > of some thread-local variable) on a MP machine, and then comparing the > result with the same program on the same MP machine with less number > of CPUs activated. > > I can't do the above test since I don't have access to a MP machine > anymore. So, I'm waiting for your response. Hmm, I just tried on an 8p ia64 machine running Linux, with python 2.3. I tried the following program, which starts 4 threads, which each execute a function which just busy loops. I then watched what went on in "top" in another terminal. If I execute the function in just one thread, then one of the CPUs goes to 99% usage. If I execute 4 threads, then 4 of the CPUs go to about %20 usage. So it does seem that a global interpreter lock is still being used in Python's implementation. Too bad, though I suppose I wasn't about to go and write computationally intensive code in Python anyway. from threading import Thread nthreads = 4 def busyloop(n=2**26): i = 0 while i < n: i = i + 1 threads = [] for i in range(nthreads): th = Thread(target=busyloop) th.start() threads.append(th) for th in threads: th.join()