allocate TWO interpreters in a C program?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Torsten Mohr

    allocate TWO interpreters in a C program?

    Hi,

    i can embed Perl into a C program and allocate MORE THAN ONE
    interpreter if i want to. They are independent from each other.

    Is this also possible in Python?


    Best regards,
    Torsten.

  • Andrew Dalke

    #2
    Re: allocate TWO interpreters in a C program?

    Torsten Mohr:[color=blue]
    > i can embed Perl into a C program and allocate MORE THAN ONE
    > interpreter if i want to. They are independent from each other.
    >
    > Is this also possible in Python?[/color]

    As no one else has answered, I'll take a stab at it, on the assumption
    that a wrong answer will be corrected.

    No, it isn't possible. Various bits of state, like exceptions, are stored
    in global variable (actually thread global I think). I think there is other
    global state, like sys.modules which contains all of the imported modules.

    There are experimental systems like PyPy which can provide
    independent interpreters but I know little about them.

    Andrew
    dalke@dalkescie ntific.com


    Comment

    • David E. Konerding DSD staff

      #3
      Re: allocate TWO interpreters in a C program?

      In article <4Vicc.16932$lt 2.13201@newsrea d1.news.pas.ear thlink.net>, Andrew Dalke wrote:[color=blue]
      > Torsten Mohr:[color=green]
      >> i can embed Perl into a C program and allocate MORE THAN ONE
      >> interpreter if i want to. They are independent from each other.
      >>
      >> Is this also possible in Python?[/color]
      >
      > As no one else has answered, I'll take a stab at it, on the assumption
      > that a wrong answer will be corrected.
      >
      > No, it isn't possible. Various bits of state, like exceptions, are stored
      > in global variable (actually thread global I think). I think there is other
      > global state, like sys.modules which contains all of the imported modules.
      >
      > There are experimental systems like PyPy which can provide
      > independent interpreters but I know little about them.
      >
      > Andrew
      > dalke@dalkescie ntific.com
      >
      >[/color]

      Actually, more than one *sub*-interpreter can be instantiated in a single C program.



      However, upon close reading, it's hardly as independent as you might hope.

      But for fun also read:

      This PEP proposes a simplified API for access to the Global Interpreter Lock (GIL) for Python extension modules. Specifically, it provides a solution for authors of complex multi-threaded extensions, where the current state of Python (i.e., the state of...


      since it seems to imply that multiple subinterpreters are not a frequently used feature.

      Dave

      Comment

      Working...