Your parents buy ONE toy for your and your sibling.
They tell you can both play with it in the toy room and only one of you can enter at a time. To make sure you respect the instructions you have to go ask them each time who can play it first.
the toy is the variable, the room is the GIL, the parents are the interpreter, you and your sibling are the threads
Your parents buy ONE toy for your and your sibling.
They tell you can both play with it in the toy room and only one of you can enter at a time. To make sure you respect the instructions you have to go ask them each time who can play it first.
the toy is the variable, the room is the GIL, the parents are the interpreter, you and your sibling are the threads
Hope it makes sense :D
Great thanks. If I understand it correctly the GIL is kind of an automatic mutex implementation. Is it correct?
Exactly, it's a giant mutex that serialises access to non thread safe resources.
And in Python - everything except IO is considered non-thread-safe.