Increase IPython history length
Asked Answered
O

2

18

I have tried increasing IPython history length following this post : Control ipython history length by changing c.TerminalInteractiveShell.history_length in ~/.ipython/profile_default/ipython_config.py.

The config file seems to be executed at startup (if I put print('test-startup') in the file, it's printed when I start IPython)

But it does not seems to have any influence, is there anyway to check the history size from inside the ipython (kinda like how you can do echo $HISTSIZE; echo $HISTFILESIZE in bash ?)

Organon answered 9/10, 2015 at 8:26 Comment(0)
F
11

Using

In[3]: %config TerminalInteractiveShell.history_length
Out[3]: 10000
Fragonard answered 9/10, 2015 at 8:34 Comment(0)
Q
20

In attempting to answer the question myself, I stumbled upon this question as well this question and found snippets that really didn't provide the OP with the complete, TL;DR information.

So for my own records and to make the answers on SO here more complete, I provided a quick implementation and check to "Increase iPython History Length."

Generate the iPython config file

$ ipython profile create <profile name>

I just wanted this for my default config, so I ran:

$ ipython profile create

Modify the ipython_config.py File

Running the above command creates an ipython_config.py file, which (on *.nix is stored at ~/.ipython/profile_default/ipython_config.py

These are the two lines that I uncommented and changed the values for:

enter image description here

Check to Ensure the Implementation Worked

Fire up iPython and run the commands found in the accepted answer above to ensure our new history_length = 100,000.

benjamingross (develop*)$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:14:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %config TerminalInteractiveShell.history_length
Out[1]: 100000
Qualm answered 13/4, 2018 at 16:8 Comment(2)
Thank you for very detailed answer! :)Sustentation
It's in the screenshot but I don't see it in the text: you also want to increase the history_load_length value to access the history in IPython.Ormiston
F
11

Using

In[3]: %config TerminalInteractiveShell.history_length
Out[3]: 10000
Fragonard answered 9/10, 2015 at 8:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.