[Python-Dev] Free threading
Fri, 17 Aug 2001 13:43:49 -0700
On Wed, Aug 08, 2001 at 11:13:27PM -0700, Aahz Maruch wrote:
> Guido van Rossum wrote:
> > Aahz:
> >> We need thread-local storage, anyway. When I'm a little farther into my
> >> work on Decimal, I'm going to take a hard look at this because context
> >> needs to be global on a per-thread basis...
> > In the C API, use PyThreadState_GetDict(): it returns a per-thread
> > dictionary. The convention is that you pick a key unique to your
> > extension module (e.g. your full extension module name) and then store
> > your per-thread data under this key.
Chicken and egg. Note that in a free threading context, there is no such
thing as _PyThreadState_Current. Thus, you can't get to that dict. Instead,
you pick up your thread state pointer from TLS (or an equiv mechanism on
> But what I was really referring to was the annoyance of having every
> method call pull in the thread-local information. Seems to me that
> there ought to be some way of making it happen magically.
Not much you can do here, except to start passing around the thread state as
a parameter. (not the interp! that is derived from the thread state, but it
can't be done the other way around)
Note that I posted some of the steps (towards free threading) last year.
Each of these are low cost, but will help set a framework for further
Greg Stein, http://www.lyra.org/