Commit 47a50c5
committed
Defer _PyRuntime_Initialize to Py_InitializeFromConfig.
When I was working on my own copy of ``Py_Initialize()`` for my own embedded interpreter that:
- manually sets ``sys.path`` (set to the base name of the exe since I story the python stlib in a zip file in it's win32 resource section)
- Disables the default explicit ``import site`` (set to 0)
- prevents the user site-packages folder from being added (set to 0),
The way I did this was with a direct copy and paste of the code in ``Py_InitializeEx`` and changed a only what I needed to implement my own ``Py_Initialize`` that suited my own needs. I hated how I needed to define ``Py_BUILD_CORE_MODULE`` and include ``#include <internal/pycore_runtime.h>`` And then checked and saw that everything but the if check in ``Py_InitializeEx`` is inside of ``Py_InitializeFromConfig`` and that the if check could be replaced easily with ``Py_IsInitialized``. Because of that I submitted this change to remove the needless code duplication here since ``Py_InitializeFromConfig`` is used anyways. It also might increase performance very slightly as a result as well for free.1 parent e8c91d9 commit 47a50c5
1 file changed
+2
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1414 | 1414 | | |
1415 | 1415 | | |
1416 | 1416 | | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
| 1417 | + | |
1426 | 1418 | | |
1427 | 1419 | | |
1428 | 1420 | | |
1429 | 1421 | | |
| 1422 | + | |
1430 | 1423 | | |
1431 | 1424 | | |
1432 | 1425 | | |
| |||
0 commit comments