[Python-ideas] Python and Concurrency
Talin
talin at acm.org
Sun Mar 25 09:59:05 CEST 2007
Thinking more about this, it seems to me that discussions of syntax for
doing parallel operations and nifty classes for synchronization are a
bit premature. The real question, it seems to me, is how to get Python
to operate concurrently at all.
Python's GIL cannot be removed without going through and fixing a
thousand different places where different threads might access shared
variables within the interpreter. Clearly, that's not the kind of work
that is going to be done in a month or less.
It might be useful to decompose that task further into some digestible
chunks. One of these chunks is garbage collection. It seems to me that
reference counting as it exists today would is a serious hindrance to
concurrency, because it requires writing to an object each time you
create a new reference. Instead, it should be possible to pass a
reference to an object between threads, without actually modifying the
object unless one of the threads actually changes an attribute.
There are a number of papers on concurrent garbage collection out there
on the web that might serve as a useful starting point. Of course, the
.Net CLR and Java VM already have collectors of this type, so maybe
those versions of Python already get this for free.
I also wonder what other things that the GIL is protecting can be broken
out as large, coherent chunks.
-- Talin
More information about the Python-ideas
mailing list