Embedding Python on Windows: why does it have to be a DLL?

后端 未结 4 611
庸人自扰
庸人自扰 2020-12-30 09:49

I\'m trying to write a software plug-in that embeds Python. On Windows the plug-in is technically a DLL (this may be relevant). The Python Windows FAQ says:

4条回答
  •  半阙折子戏
    2020-12-30 10:28

    Python needs to be a dll (with a standard name) such that your application, and the plugin, can use the same instance of python.

    Plugin dlls are already going to expect to be loading (and using python from) a python26.dll (or whichever version) - if your python is statically embedded in your exe, then two different instances of the python library would be managing the same data structures.

    If the python libraries use no static variables at all, and the compile settings are exactly the same this should not be a problem. However, generally its far safer to simply ensure that only one instance of the python interpreter is being used.

提交回复
热议问题