Jython, GILs and object locking.
Daniel Dittmar
daniel at dittmar.net
Thu Oct 16 14:44:01 EDT 2003
Harri Pesonen wrote:
> You are probably asking next "how threads can communicate". They can
> communicate with messages, and via special shared interpreter state,
> which needs a new "shared" keyword in python. Access to these shared
> variables is synchronized, all other variables are local to thread, and
> they need not be synchronized.
So you're not talking about Python threads in the meaning of the module
'thread'. Instead you want to be able to create multiple interpreters in
the same process and run them in parallel via threads. Today, the Global
in GIL is really global instead of interpreter local.
I'm not saying that this isn't a worthy goal. Server applications with
embedded Python interpreters would profit from it and it is not that
difficult to implement. (Although keeping the patches current with
Python development will be awful as adding the interpreter state will
affect every call at the C level).
I could even imagine that extension methods get an addditional flag that
signals that this methods is able to run in the GIL free environment.
Older extensions don't have that flag, so Python has to suspend all
other threads while this extension is running. This is perhaps a way to
achieve backwards compatibility.
Daniel
More information about the Python-list
mailing list