Python Apps and Python Interpreter?
I'm wondering how man开发者_JAVA百科y python interpreter would be executed for distinct python apps? Say I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?
when executing a python script, you have 1 interpreter running per process executing.
- if your application executes in a single process, you have 1 interpreter executing for each instance of your application.
- if your application launches multiple processes, then you get additional interpreters for each process launched.
- if your application uses threads, the interpreter is shared between the multiple threads which belong to the same process.
Yes, each python script is launched by a separate python interpreter process. (unless your applications are in fact a single application multi threaded of course ;) )
Assuming CPython, yes you have 'n' different interpreters running but (at least on operating systems like Windows, UNIX, and Linux) the interpreter code itself is shared.
The data areas (which includes your Python code, depending on the implementation) will be unique to each process. Any modules written in C that produce a .dll or .so (shared object) will also share the code areas between processes, but have their own data areas.
精彩评论