O'Reilly logo

Learning Cython Programming by Philip Herron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Python threading and GIL

GIL stands for Global Interpreter Lock. What this means is when you link your program against libpython.so and use it, you really have the entire Python interpreter in your code. The reason this exists is to make concurrent applications really easy. In Python, you can have two threads reading/writing to the same location (variable) Python automatically handles all of this for you; unlike say in Java, where you need to specify that everything is under the GIL in Python. There are two things to consider when talking about the GIL and what it does: instruction atomicity and read/write lock.

Atomic instructions

Remember that Cython generates the C code necessary to make it look just like any Python module that you can import. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required