Completely disable IPython output caching

大城市里の小女人 提交于 2019-12-02 19:31:27

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.

Enter

echo "__builtin__._ = True" > ~/.config/ipython/profile_default/startup/00-disable-history.py

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 with jupyter console.

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

Create an ipython profile:

!ipython profile create

The output might be (for ipython v4.0):

[ProfileCreate] Generating default config file: '/root/.ipython/profile_default/ipython_config.py'
[ProfileCreate] Generating default config file: '/root/.ipython/profile_default/ipython_kernel_config.py'

Then add the line 'c.InteractiveShell.cache_size = 0' to the ipython_kernel_config.py file by

!echo 'c.InteractiveShell.cache_size = 0' >> /root/.ipython/profile_default/ipython_kernel_config.py

Load another ipython kernel and check if this work

In [1]: 123
Out[1]: 123

In [2]: _1
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-51-21553803e553> in <module>()
----> 1 _1

NameError: name '_1' is not defined

In [3]: len(Out)
Out[3]: 0
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!