Commit 34c941c
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 38264a0 commit 34c941c
1 file changed
+2
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1438 | 1438 | | |
1439 | 1439 | | |
1440 | 1440 | | |
1441 | | - | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
| 1441 | + | |
1450 | 1442 | | |
1451 | 1443 | | |
1452 | 1444 | | |
1453 | 1445 | | |
| 1446 | + | |
1454 | 1447 | | |
1455 | 1448 | | |
1456 | 1449 | | |
| |||
0 commit comments