I am debuging a script in PyCharm. I am changing the code and run it again and again. Importing modules takes a lot of time, more than execution time of other lines of my code. I would like to avoid wasting time on importing modules. Something like restarting needed cells of my code without restarting the python kernel in scientific mode, but staying in normal mode. Can I do it?

1 Answers

0
user10414280 On

You can maintain the imported state either by using the debugger or the console.

The easiest way is to execute selections in the console after importing the modules. Select (or place the caret in) lines of code and press alt+shift+e.

In the debugger, you can evaluate expressions or alter code after modules have already been imported by setting breakpoints.

Either of these could be simplified by placing the desired modules in the __init__.py file.