[issue25991] readline example eventually consumes all memory
New submission from Bruce Frederiksen: The Example in the readline documentation (section 6.7 of the Library Reference) shows how to save your readline history in a file, and restore it each time you start Python. The problem with the Example is that it does not include a call to readline.set_history_length and the default is -1 (infinite). As a Python developer, I start Python quite a lot and had a .python_history file that was 850M bytes. Just starting Python was causing my system to thrash before the first prompt (>>>) even appeared. I suggest adding the following line to the example to avoid this: readline.set_history_length(1000) I'm not sure how far back this goes in terms of earlier versions of Python, but probably quite far. ---------- assignee: docs@python components: Documentation messages: 257325 nosy: dangyogi, docs@python priority: normal severity: normal status: open title: readline example eventually consumes all memory type: resource usage versions: Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- keywords: +easy nosy: +ezio.melotti stage: -> needs patch type: resource usage -> enhancement versions: +Python 2.7, Python 3.5, Python 3.6 -Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Martin Panter added the comment: What version of Readline are you using? Is it perhaps Editline (libedit)? When I experimented with Editline on Linux once, I think I saw the history file doubling in size every time I ran Python. Maybe that is what you are seeing. ---------- nosy: +martin.panter _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Daniel Dye added the comment: Add a history length of 1000 lines Default is -1 (infinite), which may grow unruly ---------- keywords: +patch nosy: +Daniel Dye Added file: http://bugs.python.org/file41544/doc_library_readline.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Roundup Robot added the comment: New changeset 9a2c891a4333 by Ezio Melotti in branch '2.7': #25991: fix readline example to limit history size. Patch by Daniel Dye. https://hg.python.org/cpython/rev/9a2c891a4333 New changeset 416db1a2fb81 by Ezio Melotti in branch '3.5': #25991: fix readline example to limit history size. Patch by Daniel Dye. https://hg.python.org/cpython/rev/416db1a2fb81 New changeset cb08e5271cc0 by Ezio Melotti in branch 'default': #25991: merge with 3.5. https://hg.python.org/cpython/rev/cb08e5271cc0 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Ezio Melotti added the comment: Fixed, thanks for the patch! ---------- resolution: -> fixed stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
Martin Panter added the comment: Thanks Ezio for handling this. Ignore my previous comment; I missed the key word “example” :) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25991> _______________________________________
participants (5)
-
Bruce Frederiksen
-
Daniel Dye
-
Ezio Melotti
-
Martin Panter
-
Roundup Robot