By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,920 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,920 IT Pros & Developers. It's quick & easy.

Multiple interpreters in a single process

P: n/a
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,

--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <bt**********@atlantis.news.tpi.pl>,
Maciej Sobczak <no*****@no.spam.com> wrote:

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.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

A: No.
Q: Is top-posting okay?
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.