I'm dealing with some GB-sized numpy arrays in IPython. When I delete them, I definitely want them gone, in order to recover the memory. IPythons output cache is quite annoying there, as it keeps the objects alive even after deleting the last actively intended reference to them. I already set
c.TerminalInteractiveShell.cache_size = 0
in the IPython configuration, but this only disables caching of entries to _oh
, the other variables like _
, __
and so on are still created. I'm also aware of %xdel
, but anyways, I'd prefer to disable it completely, as I rarely use the output history anyways, so that a plain del
would work again right away.
Looking at IPython/core/displayhook.py Line 209-214 I would say that it is not configurable. You could try making a PR to add an option to disable it totally.
Seems that we can suppress the output cache by putting a ";" at the end of the line now.
See http://ipython.org/ipython-doc/stable/interactive/tips.html#suppress-output
Enter
and your history should be gone.
Edit:
Seems like the path to the config directory is sometimes a bit different, either
~/.config/ipython
or just~/.ipython/
. So just check which one you got and adjust the path accordingly. The solution still works withjupyter console
.Create an ipython profile:
The output might be (for ipython v4.0):
Then add the line
'c.InteractiveShell.cache_size = 0'
to theipython_kernel_config.py
file byLoad another ipython kernel and check if this work