[IPython-dev] History

Thomas Kluyver takowl at gmail.com
Fri Feb 18 08:37:06 EST 2011


On 18 February 2011 13:06, Hans Meine <hans_meine at gmx.net> wrote:

> I like having a history limit of 150,000 commands.  Why not?  Same as
> MinRK:
> As long as I dimly remember that I solved a particular problem on the
> commandline in the middle of last year, why should my computer have
> forgotten
> about it?  (Yes, privacy issues might arise, but there are countermeasures
> here, too.)
>
> But I could very well live with magic commands for this use case, i.e. with
> limited readline history.
>

I'll ensure that this can all be tuned through a config file. I've gone with
loading the last 1000 into readline history for now, and I've not yet
implemented any limit on the database size.


> Here, you're assuming that the file is "very small", while AFAICS it might
> be
> at least some megabytes.  So why have this redundancy?
>

I tested it briefly yesterday evening. After about 140 commands, storing
both raw and translated all the time, the database was about 14kB; i.e.
about 100 bytes per line. If we assume the lines in my test were half what's
typical, 150,000 commands would be 30MB. In disk space terms, that's not
worth worrying about (unless we do IPython for embedded systems ;-)).

Here's the code:
https://github.com/takluyver/ipython/tree/sqlite-history
It's still very much a work in progress - I haven't hooked up all the magic
commands to access previous sessions. But it writes to the database, reloads
lines into readline (in the order I described), and searching the database
with "%hist -g thing" works. I'll make a pull request once it's a bit more
complete.

As an aside, there are a few odds and ends left using the pickleshare DB -
on my system, there's still syscmdlist and dhist (directory history). I've
got nothing against pickleshare - it seems to work perfectly well - but is
it worth looking at simplifying those odds and ends of storage? It looks
like it's using pickle to dump to/load from file: is it simpler to call
pickle directly?

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110218/cafe7af5/attachment.html>


More information about the IPython-dev mailing list