[Python-Dev] Free threading

Paul Prescod paulp@ActiveState.com
Tue, 07 Aug 2001 13:17:02 -0700

Guido van Rossum wrote:
> ...
> Nothing stops you from doing that -- the intention is that it's
> possible. 

I didn't ask the question properly. You can run multiple interpreters in
multiple threads but they share a GIL, right? I'm really asking whether
multiple interpreters can be as independent of each other as any other
bit of carefuly written re-entrant C code.

> ... Immutable objects (like strings and ints) and all built-in
> type objects (including extension types) are shared between all
> interpreters.  Interned strings are shared.  Exceptions are shared
> (there may actually be a bug related to initializing exceptions that I
> still have to track down).  Extension modules that have global state
> may cause additional confusion.  Operating system resources like file
> descriptors are shared.

It might be interesting if there were a module that allowed the Python
programmer to spawn new interpreters on new threads from within Python
and a way to share primitive data structures between them. My
understanding is that Perl and Tcl both use this "independent threads"
model which scales really well on SMP but seems to me to be pretty
brutal to program for. Nevertheless I can see how it would be useful
where all you care about is SMP performance.

Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook