[Python-Dev] GIL removal question
Guido van Rossum
guido at python.org
Fri Aug 12 23:38:25 CEST 2011
On Fri, Aug 12, 2011 at 12:57 PM, Rene Nejsum <rene at stranden.com> wrote:
> I think I understand the background and need for GIL. Without it Python
> programs would have been cluttered with lock/synchronized statements and
> C-extensions would be harder to write.
No, sorry, the first half of this is incorrect: with or without the
GIL *Python* code would need the same amount of fine-grained locking.
(The part about C extensions is correct.) I am butting in because this
is a common misunderstanding that really needs to be squashed whenever
it is aired -- the GIL does *not* help Python code to synchronize. A
thread-switch can occur between any two bytecode opcodes. Without the
GIL, atomic operations (e.g. dict lookups that doesn't require
evaluation of __eq__ or __hash__ implemented in Python) are still
supposed to be atomic.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list