3 ms·
If your interpreter takes 3 seconds to start up there's something seriously wrong. Hopefully that's taking into account the human time to hit ^D and an up arrow
by JulianWasTaken 14y ago
If your interpreter takes 3 seconds to start up there's something seriously wrong. Hopefully that's taking into account the human time to hit ^D and an up arrow, plus whatever time it takes to do all your imports or whatever. Assuming that was what was meant, then you probably really just want to learn about `python -i`.
I agree that the real solution here is "write unit tests", but even if you like an interactive interpreter, seriously, just restart it, it should take a half a second at most (and yes, reload() is broken by design, though sometimes it happens not to matter).
- bjpless 14y ago3 seconds includes closing AND starting the IPython shell. Typing "exit" or ctrl + d + return adds a little time and is generally annoying. The builtin Python shell is admittedly faster to start/stop but IPython's features rock.
- JulianWasTaken 14y agoAh, OK, fair enough. FWIW you might also like checking out https://github.com/ludios/Pyquitter https://github.com/ludios/Pyquitter. I use it occasionally when I want something like this, you could rig it to start iPython's main(). It also doesn't use inotify but that'd be fairly trivial to add.
- bjpless 14y agoAh I like it, thanks. From a quick glance, it seems like it just restarts the entire child process on change. The big (but admittedly) dangerous feature of my script is that you can maintain state inside of the embedded shell on module reload. I like pyquitter looks like a cool generalization, though, of the basic idea.
- dbaupp 14y agoFor those who didn't know (like me), from the python man-page: -i When a script is passed as first argument or the -c option is used, enter interactive mode after executing the script or the command. It does not read the $PYTHONSTARTUP file. This can be useful to inspect global variables or a stack trace when a script raises an exception. http://man.cx/python http://man.cx/python
- deleted 14y ago[deleted]