Closed kxmh42 closed 1 year ago
Coconut already has a Jupyter kernel? I don't understand what this PR is trying to add.
Python has both ipython
and jupyter console
, and there are reasons why they have remained separate, even though they look almost identical. Jupyter is used in the data science community, but Python is a general-purpose language, and those who use it to write e.g. webapps, don't usually use Jupyter. But they do use a REPL like ipython
. I think the same arguments apply to Coconut.
I just did a simple test on an environment with only Coconut. When I ran pip install ipython
, it installed 15 additional packages, and my site-packages
directory grew by 23 MB. When I ran pip install jupyter
, which is required to run a Jupyter console, it installed 82 additional packages and site-packages
grew by 150 MB.
Running coconut --jupyter console
spawns a server and a client and takes up 150 MB of RAM. Running icoconut
spawns only one process and uses about 70 MB of RAM. I know that bandwidth, storage and RAM are cheap these days, but it really seems like an overkill to install 82 additional packages just to have something as basic as a multiline REPL.
Given that ipython
already supports the coconut
magic, I think it would be useful to have a REPL that simply applies this magic to each input line/cell and has no additional dependencies.
BTW, when I run coconut --jupyter console
in Python 3.11, I get the following warning:
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
It's apparently caused by something from icoconut/root.py
that is then imported into icoconut/__init__.py
. When I moved my code out of the icoconut
directory, the warning disappeared.
If you want a lightweight multiline repl, you can just use Coconut's built-in interpreter. And if you need something more heavyweight that has support for e.g. IPython magics, then you can use coconut --jupyter console
. I don't think there's really a need for something like this in-between those two.
As for the warning, it's caused by Jupyter/IPython, not Coconut (see https://stackoverflow.com/questions/75114841/debugger-warning-from-ipython-frozen-modules-python-3-11). You can set the environment variable that the warning suggests to suppress it, but there's not much else that I can do about it on my end, at least as far as I'm aware.
Understood. It seems that my arguments didn't sway you. But is there a way to go back to a multiline statement in Coconut's built-in interpreter?
I'm not exactly sure what you mean by "go back", but the interpreter has history that includes multiline statements, so if you press the up arrow you should be able to go back to a previous multiline statement that way.
Testing it now, it looks like the history keeps track of each line in a multiline statement separately unless you copy all of the lines in at once. That seems like it's a bug, though. Feel free to raise another issue for that.
I use
ipython
a lot, and wanted to have something similar for Coconut.icoconut
is basicallyipython
that interprets its input as Coconut by default. This is my first PR here, I hope I didn't miss anything from the guidelines :)