Tuesday, September 30, 2008

Global Interpreter Lock in Python

Recently we were having an interesting discussion in our team about the threading and performance in Python. One of the key concerns was the Global Interpreter Lock (GIL) in Python. GIL is acquired before any thread accesses any of the Python objects. So if you are writing any C extensions and if you would like to manipulate any Python object, you must first acquire the lock and then only you can read/write/modify any object. Due to this, you will always have considerable of your code sequential.

There is a lot of discussion about GIL on the web. You will particularly find this page useful.

Someone suggested that Lua, by design, doesn't have any such constraints. It performs very well when it comes to multithreading. As I don't have much experience in programming in Lua, I don't know if that claim is true or not.

I am also not sure if Perl has any such global locks issue. I tried to Google it, but didn't find anything useful.

No comments: