0 votes
in Python by
What is GIL and what are some of the ways to get around it?

1 Answer

0 votes
by

GIL stands for the Global Interpreter Lock and it is a mechanism Python is using for concurrency. It is built in deep into Python system and it is not possible at the moment to get rid of it. The major downside of GIL is that it makes threading not truly concurrent. It locks the interpreter, and even though it looks like you are working with threads, they are not executed at the same time, resulting in performance losses. Here are some ways of getting around it:

multiprocessing module. It lets you spawn new Python processes and manage them the same way you would manage threads

asyncio module. It effectively enables asyncronous programming and adds the async/await syntax. While it does not solve the GIL problem, it will make the code way more readable and clearer.

Stackless Python. This is a fork of Python without GIL. It’s most notable use is as a backend for the EVE Online game.

Related questions

0 votes
asked May 17, 2019 in Python by Derya
0 votes
asked Jul 2, 2020 in Python by GeorgeBell
...