[PEAK] Re: [Zope3-dev] Re: Virtual Pythons
Phillip J. Eby
pje at telecommunity.com
Mon Aug 2 11:04:56 EDT 2004
At 01:26 PM 8/2/04 +0800, Tim Hoffman wrote:
>Would each ModuleSpace also have its own globals
Every module has its own globals, so each module space's copy of a given
module would have its own, separate globals.
By the way, a bit of follow-up on module spaces: it appears that CPython
has a C API for creating "multiple interpreters", that is used by
mod_python and some other embedding uses of Python. It looks to me as
though this API could be wrapped in a Pyrex module for use from Python,
with a bit of work, and that's probably how module spaces will get
implemented, as 'Interpreter' objects. Each module space's import hook
will reset the current thread's interpreter to the interpreter associated
with that module space. Then, any C--level code that does importing, will
see the correct copy of sys.modules, __builtins__, etc.
The very cool thing about this is that basically all the hard work of
getting C code to see the right sys module (including things like managing
all the special sys variables like exception states and such) will be
handled by Python's internal multi-interpreter support.
The not-so-cool thing is that Martin Loewis seems to be very down on
mulitple interpreters, calling them "essentially ill-designed" on
Python-Dev. If the BDFL agrees with that take, I'm not sure whether
building on it is a good idea.
More information about the PEAK
mailing list