3 ms·
The GIL is a condition variable and a mutex. Nothing fancy. In a single threaded program, it gets acquired once, if at all.
by smegel 11y ago
The GIL is a condition variable and a mutex. Nothing fancy. In a single threaded program, it gets acquired once, if at all.
- eveningcoffee 11y agoMutex and a shared condition variable are expensive compared to the single instruction. But I had an impression that it is acquired before every atomic Python instruction and it looks that it is actually acquired for group of predefined number of instructions (100) that then are executed inside one GIL time frame [0]. Therefore it actually should not be a big obstacle to make Python code run fast by a JIT compiler. [0] http://www.dabeaz.com/python/GIL.pdf http://www.dabeaz.com/python/GIL.pdf