8 ms·
PEP 762 – REPL-acing the default REPL
- wodenokoto 2y agoI feel like there’s a missing discussion as to why they aren’t going with Ipython
- Miniminix 2y agothey did acknowledge some alternatives, but I agree more discussion would have been nice. FTA - Option 3: Using other existing REPL implementations: The authors looked at several alternatives like IPython, bpython, ptpython, and xonsh. While all the above are impressive projects, in the end PyREPL was chosen for its combination of maturity, feature set, and lack of additional dependencies. Another key factor was the alignment with PyPy’s implementation.
- BiteCode_dev 2y agoIPython is huge: 15,5 Mo without any extras. Python is 150mo. Hard to justify that 10% of the lines of code, source of bugs and maintenance only go to the shell.
- somat 2y agoI am curious about your suffixes. I mean, I understand the post fine, but I have never seen the units (Mo, mo) before and am wondering where they came from. I would guess mo is megabytes(megaoctets?) and Mo is gigabytes(is ipython really 15GB? yikes)
- mimischi 2y agoLooks like it’s octets: https://en.m.wikipedia.org/wiki/Octet_(computing) https://en.m.wikipedia.org/wiki/Octet_(computing)
- Numerlor 2y agoI think I remember seeing something about MB=Mo in french, the casing is probably safe to ignore in the gp as ipython is definitely not 15gb
- BiteCode_dev 2y agoyeah sorry mb, french comming out
- wodenokoto 2y agoOT, but I love your newsletter! Didn’t notice your username until you wrote “French”
- BiteCode_dev 2y agoThat's lovely to hear. It's great hearing it in general, but given the HN community is picky, it feels even better.
- cycomanic 2y agoI think ptpython would have been a much better choice. It is relatively small with few dependencies, much more feature complete, importantly it can run in windows terminal AFAIK which pyrepl can't at the moment. I suspect it has also seen much more testing because it is much more widely used. This really seems like a missed opportunity, instead of another repl that will only be used by developers (they even stated that as primary motivation) who can't install anything else, they could have taken a repl that would actually be widely used to integrate into other programs... Instead I suspect pyrepl will eventually experience the same fate as the current repl, i.e. it will languish with no development and get replaced again eventually because it has become to painful to adjust to changes in the rest of the language and changes in terminals.
- zem 2y agofewer dependencies than ipython perhaps, but still unacceptable for something that needs to be shipped as part of the language. also I feel that you are unduly pessimistic about its chances and that the PEP is right about this one - being written in python rather than C will get it a ton of contributions from the community if anything is found lacking. particularly since you won't necessarily need to know a ton about python internals to just contribute to the repl
- aroberge 2y agoIf I remember correctly, unlike the standard Python interpreter, ptpython does not support the replacement of sys.excepthook by a custom one. I know that I look at seeing if I could have it support friendly-traceback but couldn't.
- KaiserPro 2y agoI think the issue with iPython is that it's really quire large and has a non-trivial number of third-party dependencies that would need to be dealt with. Python already has a million libraries built in, adding more in would be a pain. Plus there is the politics of making something "core" when the maintainers aren't part of the core python team.
- benrutter 2y agoWould be interesting to their reasons, but I'd be surprised if they had chosen it. I freaking love ipython, but it has a bunch of dependencies and extends far beyond just being a repl for the language and introduces things like magic commands, execute as shell, fallback logic etc. Given how tight python keeps it's standard library, it seems pretty much imposssible to imagine those kind of advance features being developed while providing the stability that python normally asks from it's standard library.
- 0cf8612b2e1e 2y agoI just tested installing ipython and it came with 17 dependencies. Some of which are probably pretty heavy and/or way too in flux to make it into the standard library.
- krick 2y agoThat's fair. But I wonder if developing a "better REPL" won't be essentially a bug-ridden implementation of half of the ipython. Like that lisp joke... So I don't know if community work to de-couple ipython into "essential" and "jupyter-stuff" is any viable, but I'd really consider it before committing to write the same thing (but worse) from scratch.
- deleted 2y ago[deleted]
- 12_throw_away 2y agoI'm sure it's for exactly the same reason that I'm often hesitant to install it - huge dependencies: $ pip show ipython [...] Requires: appnope, backcall, decorator, jedi, matplotlib-inline, pexpect, pickleshare, prompt-toolkit, pygments, stack-data, traitlets
- 12_throw_away 2y agoAlso, I'm genuinely thrilled to see cross-pollination from pypy back to cpython, so am actually really glad they did it this way - as cpython's JIT becomes production-ready, maybe more bits of python will become be self-hosting?
- boxed 2y agoAlso, jedi depends on parso. Parso does not yet support `match` (which is a big problem for me, as it means I need to switch AST library backing mutmut).
- zahlman 2y agoMy guess is that it's not really designed to be fully severed from Jupyter. It certainly shouldn't require Matplotlib to run a console REPL.
- 0cf8612b2e1e 2y agoI am pretty sure matplotlib is not required. That is just a convenience library that improves the notebook experience if matplotlib is loaded. So you no longer need to run the magic function ‘%matplotlib inline’
- wodenokoto 2y agoWhile I haven’t figured out how, it is my understanding that there exists a workflow where you have ipython/jupyter installed once, and then have them use the Python interpreter and modules associated with each project. But I’ve never figured it out and instead have a `requirements-dev.txt` with Jupyter and Ipython in every project because they are so good to have on hand when developing
- o11c 2y agoThe horrible startup time is probably part of it: $ time ipython3 -c 'pass' real 0m1.083s user 0m0.355s sys 0m0.093s
- Macha 2y agoIs this worse than the standard python interpreter? Python startup time is a big reason I've moved a bunch of my personal utilities to Rust.
- o11c 2y agoCPython startup is pretty fast assuming you aren't importing heavy modules. Of course, any nontrivial program needs to do some imports. Some examples: 0.01s cpython - with site disabled 0.04s pypy - with site disabled 0.04s cpython - import site and/or built-in modules 0.08s pypy - import site and/or built-in modules 0.13s cpython - import requests 0.31s pypy - import requests 0.31s cpython - import IPython 0.72s pypy - import IPython 1.1s cpython - run ipython nop 2.1s pypy - run ipython nop (the last digit of all of these numbers often varies a little) Since Python's startup is reasonably fast, it's possible to use it for interactive tools even with heavy imports by spawning a daemon the first time, and just forwarding the requests over a socket. This is mildly annoying but not particularly difficult.
- deleted 2y ago[deleted]
- behnamoh 2y agoI want a Lisp-like REPL for my Python programs that is available to the user who runs my compiled Python program (so, I want compilation as well). The user will be able to interact with my program (instead of just running the main function), change function definitions, etc. and mold the program to their specific use case while it's running.
- ks2048 2y agoSome things are a bit awkward, but what specifically can't you really do in a Python REPL? You can dynamically overwrite functions in an imported module, you can re-import modules with importlib, etc. I ask because my Lisp experience is limited.
- behnamoh 2y agoLisp REPL keeps the state of the program because it is a live image. With Python REPL you need to rerun the program to set the variables to their values.
- ks2048 2y agoYou can create a file, example.py: import time value = "foo" def go(): for i in range(10): print("...", i, value) time.sleep(3) Then, in repl, import example import threading thread = threading.Thread(target=example.go) thread.start() It will slowly print out messages and you can do "example.value = 'bar'" in the REPL and it will change.
- behnamoh 2y agoit's not the same though—In Lisp, when you compile your program, a Lisp run-time is attached to it so you can either run the program normally (like any binary) or you could REPL into the program and see what the values of variables are (these values were set at compile time). This is helpful when you have a large dataset you don't want to load over and over.
- klreslx 2y agoI don't see the point. People who want Jupyter or an IDE know where to find it. Other people who want the basic REPL and mostly use editors anyway are annoyed. Well, perhaps the usual suspects can get another infoworld self-promotion article out of it.
- influx 2y agoThere's a tremendous power with defaults and with "batteries included".
- rgollert 2y agoThe same people removed distutils, which is why at my company we had to update several internal C-extensions. In these decisions the only thing that matters is if Microsoft, Facebook, Bloomberg or one of their employees is pleased.
- itishappy 2y agoIt looks like a lot of care went in to disclosing this and providing replacements. Can I ask what you were using it for? https://peps.python.org/pep-0632/ https://peps.python.org/pep-0632/
- cozzyd 2y agoThe deprecation of distutils caused a ton of havoc for e.g. FreeCAD
- itishappy 2y agoI won't argue with that, but I would like to understand why. If I'm on the right path with these forum threads, it looks like there were issues with how Debian packages python? https://forum.freecad.org/viewtopic.php?t=67985 https://forum.freecad.org/viewtopic.php?t=67985 https://github.com/FreeCAD/FreeCAD/pull/6753 https://github.com/FreeCAD/FreeCAD/pull/6753 https://ffy00.github.io/blog/02-python-debian-and-the-install-locations/ https://ffy00.github.io/blog/02-python-debian-and-the-instal...
- dwaltrip 2y agoThis is great. Using the default REPL was always painful after getting used to ptpython. Looking forward to trying it!
- vanous 2y agoIt's a good start, and please do more... Even small QOL improvements like tab completion for filenames are important and is what makes me to install ipython at this point.
- wiseowise 2y ago> The new REPL released in Python 3.13 aims to provide modern features No `vi` mode and not planned. Very modern. https://github.com/python/cpython/issues/118840 https://github.com/python/cpython/issues/118840
- HellsMaddy 2y agoHonestly, even as a neovim user, I don’t find vi mode to be very ergonomic for interactive prompts, and I prefer emacs-style keybindings in these cases. The only time I feel the need for vi mode is when I want to copy something, but in that case I already have that capability through tmux copy-mode. I would prefer if the team prioritizes python-specific functionality first and foremost.
- krick 2y agoMe too, but I actually think the complaint is totally valid. I mean, somebody does use it, and it isn't some horribly obscure feature, it's built into most terminals, it's pretty much standard Linux functionality at this point, and old REPL does support it, so when you introduce new default REPL, but then say "uh, no, we don't use that shit you use, so fuck off and use the old REPL, loser" it's not very nice. (And even if they didn't outright call him a loser in that thread, it's still not very nice.) In short, the fact you, me and these guys don't understand why anybody used vi-mode doesn't mean shit. It came before us, apparently still exists, and well may outlive your neovim and PyREPL. Prioritizing other stuff is one thing, dismissing and closing the issue because "nobody (i.e., me) needs that shit" is another.
- Affric 2y agoI will be staying on ptpython then.
- IshKebab 2y agoYeah it is. Vi is ancient and not at all modern or use friendly. Look at that bug report! They're complaining they can't go up to the previous command by pressing ESC k. Instead they have to press.... up. Ye gads.
- devnonymous 2y agoI replied here earlier with my own pet project to essentially say that you don't need a whole lot of complexity to solve for QOL improvements in the console but was promptly downvoted, I thought that was fair and so deleted my comment. However, now I do feel the need to say this - you really do not need a whole lot to enhance your productivity on the python REPL by a large factor, if you take advantage of some simple built-in facilities: A. Understand the use of the PYTHONSTARTUP environment variable. This alone is a big advantage. It'll allow you to you automatically import often needed modules and declare helpers that you always seem to need. B. Once you've gotten used to that, Wrap the built-in module code (or I presume pyrepl) to add the little things that you need and point PYTHONSTARTUP to it C. Enjoy At the risk of being downvoted again (not that it matters, so won't delete this time), here again, shameless plug - https://github.com/lonetwin/pythonrc https://github.com/lonetwin/pythonrc
- AcerbicZero 2y agoI have been "advocating" (i.e. complaining) for better REPLs basically the entire time I've been writing code - One of my favorite pasttimes is getting all flustered and trying to throw enough extensions and custom code to get an offline REPL.it style experience out of VS Code for whatever language I'm playing with at the moment, and lately its kinda been working (for Ruby, at least). I am also very found of pointing out that Powershell still has one of the best ISE's/IDE's in the game for this kind of stuff. One window for editing, a terminal in which whatever you edit runs, and then access to every var/function/etc you just touched in that same terminal is a joyous experience that is shockingly hard to recreate for many languages. Hell half the time I'm just testing out random syntax or a portion of a function and being able to do that in the same session as the script I'm working is awesome. With enough abuse VS code comes close (for Ruby at least, thank you Pry!) but it would be nice to get a similar experience with Python; I've used a few of the existing REPL options for python, but most of them require you to actually figure out pdb and even then it wasn't as tightly integrated as what I actually wanted.
- zahlman 2y agoI usually just have one terminal window open with the Python REPL, and another open with a text editor. Works fine for me, although admittedly it was slightly more convenient back when `reload` was a builtin. (That's maybe the one thing I miss from 2.x, if I had to pick one. Sure, it doesn't honestly really make sense as a builtin; but it could have been added to `site` or something.)
- banku_brougham 2y agoptpython is great in this usage
- AcerbicZero 2y agoI'll have to check it out! :)
- PyWoody 2y agoAre you referring to the builtin `reload` found at `importlib.reload`? [0] I use it all the time in debugging. Works great in conjunction with `breakpoint`s for quick iterations. [0] https://docs.python.org/3/library/importlib.html#importlib.reload https://docs.python.org/3/library/importlib.html#importlib.r...
- zahlman 2y agoNow that I've actually gone and read the PEP instead of just relying on my familiarity with the changes as described elsewhere (and experienced for myself): ... Wow, significant portions of that come across to me as AI-generated. I'm pretty sure this is the first time I've gotten that impression from a PEP.
- GaryNumanVevo 2y agoThey need to borrow the Julia repl's behavior and be able to run pip commands after hitting `]` in the repl Also it would be great for a `?` directive to print docstrings please.