Python Embedded Instances
Tim Peters
tim.one at comcast.net
Sat Jul 13 03:26:05 EDT 2002
[Andrew MacIntyre]
> I don't believe the Python core in its current form supports separate
> interpreter instances in the one application (something I understand Tcl
> can support).
It does, but only at the C level (you can't create a new interpreter from
pure Python code). See the docs for Py_NewInterpreter() in the
"Initialization, Finalization, and Threads" chapter of the Python/C API
manual.
> You may be able to deal with this, if each "instance" is totally distinct,
> by using Python threads - the master Python thread starts a thread for
> each document. This probably has risks though (globals, preserved state
> in some library modules, etc).
Those are the kinds of risks Py_NewInterpreter() tries to save you from.
See the docs for more. We almost never hear about bugs in this subsystem,
which I expect means it's rarely used.
More information about the Python-list
mailing list