Issue 25991: readline example eventually consumes all memory (original) (raw)

Created on 2016-01-02 04:28 by dangyogi, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
doc_library_readline.patch Daniel Dye,2016-01-09 09:47 Patch the Doc/library/readline.rst file review
Messages (6)
msg257325 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2016-01-02 04:28
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.
msg257778 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-08 21:03
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.
msg257813 - (view) Author: Daniel Dye (Daniel Dye) Date: 2016-01-09 09:47
Add a history length of 1000 lines Default is -1 (infinite), which may grow unruly
msg258020 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-11 21:31
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
msg258021 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-01-11 21:32
Fixed, thanks for the patch!
msg258053 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-12 02:02
Thanks Ezio for handling this. Ignore my previous comment; I missed the key word “example” :)
History
Date User Action Args
2022-04-11 14:58:25 admin set github: 70179
2016-01-12 02:02:18 martin.panter set messages: +
2016-01-11 21:32:45 ezio.melotti set status: open -> closedresolution: fixedmessages: + stage: needs patch -> resolved
2016-01-11 21:31:51 python-dev set nosy: + python-devmessages: +
2016-01-09 09:47:48 Daniel Dye set files: + doc_library_readline.patchnosy: + Daniel Dyemessages: + keywords: + patch
2016-01-08 21:03:51 martin.panter set nosy: + martin.pantermessages: +
2016-01-08 17:50:19 ezio.melotti set versions: + Python 2.7, Python 3.5, Python 3.6, - Python 3.4nosy: + ezio.melottikeywords: + easytype: resource usage -> enhancementstage: needs patch
2016-01-02 04:28:53 dangyogi create