More than one interpreter per process?

sturlamolden sturlamolden at yahoo.no
Tue Dec 18 10:06:58 EST 2007


On 18 Des, 10:24, Roger Binns <rog... at rogerbinns.com> wrote:

> The biggest stumbling block is what to do when the external environment
> makes a new thread and then eventually calls back into Python.  It is
> hard to know which interpretter that callback should go to.

Not if you explicitely hav to pass a pointer to the interpreter in
every API call, which is what I suggested.


> You are also asking for every extension module to have to be changed.
> The vast majority are not part of the Python source tree and would also
> have to support the versions before a change like this.

It would break a lot of stuff.

But porting could be automated by a simple Python script. It just
involves changing PySomething(...) to PySomething(env, ...), with env
being a pointer to the interpreter. Since an extension only needs to
know about a single interpreter, it could possibly be done by
preprocessor macros:

#define PySomething(var) PySomething(env, var)

> You would have more luck getting this sort of change into Python 3 since
> that requires most extension modules to be modified a bit (eg to deal
> with string and unicode issues).

PEPs are closed for Python 3.




More information about the Python-list mailing list