Multiple interpreters in a single process

Discussion in 'Python' started by Maciej Sobczak, Jan 5, 2004.

  1. 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/
    Maciej Sobczak, Jan 5, 2004
    #1
    1. Advertising

  2. Maciej Sobczak

    Aahz Guest

    In article <btbso8$etl$>,
    Maciej Sobczak <> 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 () <*> http://www.pythoncraft.com/

    A: No.
    Q: Is top-posting okay?
    Aahz, Jan 14, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Miller
    Replies:
    4
    Views:
    319
    Paul Miller
    Jan 23, 2004
  2. bmatt
    Replies:
    2
    Views:
    308
    Frithiof Andreas Jensen
    Sep 29, 2004
  3. Replies:
    0
    Views:
    261
  4. vishnu
    Replies:
    0
    Views:
    375
    vishnu
    Mar 31, 2007
  5. Marcin Kalicinski
    Replies:
    3
    Views:
    600
    Graham Dumpleton
    Jun 10, 2007
Loading...

Share This Page