4 ms·
I looked at doing this several years ago on Windows and I seem to recall that Python had a lot of global state. So you could only have one instance of the Pytho
by FigBug 10y ago
I looked at doing this several years ago on Windows and I seem to recall that Python had a lot of global state. So you could only have one instance of the Python VM and therefore only Python script running at once. Is this still the case?
In the end, for me, it was easier to share file formats between the C++ and Python and run the Python scripts out of process.
- istotex 10y agoA big advantage of embedding the Python interpreter is that it cannot be replaced by a malicious program pretending to be Python. It’s going to be internal to your binary, so it will be difficult for someone to intercept the scripts you are executing, or modify the functionality of your application. There are only a handful of cases where it is worthwhile to embed the Python interpreter. For most cases, running Python in a separate process is probably the best approach.
- drdaeman 10y agoThere are sub-interpreters: https://docs.python.org/3/c-api/init.html#sub-interpreter-support https://docs.python.org/3/c-api/init.html#sub-interpreter-su...
- _wmd 10y agoSubinterpreters still share a lock and suffer from compatibility issues with C extension modules as the module interface only exports a very primitive notion of per-subinterpreter state, they're pretty much not all that safe to use unless you have a very constrained environment