Multiple interpreters in a single process

M

Maciej Sobczak

Hi,

I'm interested in embedding the Python interpreter in a C++ application.
What I miss is the possibility to create many different interpreters, so
that the stuff that is running in one interpreter does not influence the
other. In essence, the interpreter can be used in different modules of a
single application. It would be nice to isolate them.

There are two possibilities:

1. The interpreters need to run in paraller (from different threads of
the master application). Definitely, separate interpreters are needed.

2. Different modules use a single Python interpreter in non-overlapping
times. At least the possibility to clean up the interpreter is needed.

Is this problem easy to solve? Or maybe are there alternative approaches
(switchable dictionaries, etc.)?

Thank you very much,
 
A

Aahz

I'm interested in embedding the Python interpreter in a C++ application.
What I miss is the possibility to create many different interpreters, so
that the stuff that is running in one interpreter does not influence the
other. In essence, the interpreter can be used in different modules of a
single application. It would be nice to isolate them.

Unfortunately, it's not really possible to do that. The problem is that
Python is designed to interface to C libraries, many of which use global
static variables. So Python doesn't really try to allow isolated Python
instances. Your best bet if you need true isolation is to run multiple
processes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top