ipython / ipython

Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.

Home Page:https://ipython.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No way to set implementation-specific options for python interpreter

ngoldbaum opened this issue · comments

Currently there's no way to pass -X options to python via the IPython CLI:

goldbaum at Nathans-MBP in ~/Documents
○  ipython -Xgil=0
[TerminalIPythonApp] WARNING | Unrecognized alias: 'Xgil', it will have no effect.
[TerminalIPythonApp] CRITICAL | Bad config encountered during initialization: Error loading argument Xgil=['0'], values whose keys begin with an uppercase char must be Config instances: 'Xgil', DeferredConfigString('0')

This is the way to force the GIL to be disabled at runtime in the free-threaded python build:

goldbaum at Nathans-MBP in ~/Documents
○  python -Xgil=0
Python 3.13.0b2 experimental free-threading build (main, Jun 11 2024, 14:35:59) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys._is_gil_enabled()
False

CPython supports a number of other options via -X: https://docs.python.org/3.13/using/cmdline.html#cmdoption-X

You should be able to start IPython with python -m IPython, and pass any other options to Python, I don't have 3.13 built, but my guess is python -Xgil=0 -m IPython will do what you wish.

That makes sense, thanks! Feel free to close if you don't think IPython should grow the ability to directly pass that on via the CLI.

I think for some other options it make sens, but for those, there is not much we can do as the Python interpreter has already started and imported quite a bit of things before we reach the point where we look at options.

I'm going to close as there is nothing we can do in this specific case, but if you see other options it make sens to support feel free to open another issue.