I'm wondering how many 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?
-
Too vague to answer. Are these web apps? Desktop gui apps? Command-line apps? Are they servers? Clients?S.Lott– S.Lott2011年09月20日 10:11:43 +00:00Commented Sep 20, 2011 at 10:11
3 Answers 3
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.
Comments
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 ;) )
Comments
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.