[New-bugs-announce] [issue1708] improvements for linecache

umaxx report at bugs.python.org
Sun Dec 30 15:18:38 CET 2007


New submission from umaxx:

here comes a simple patch for linecache core module, which does the
following:

- remove double comment
- instead of adding all lines with readlines() to the cache, just add
seek points for every line
- return lines from cached seek-points instead directly from dict-cache

advantages of this patch:

- reading lines from very big files (>1GB) is no problem anymore
- linecache can handle a large number of large files now 
- updatecache() is faster now because "for line in fp:" is faster than
readlines()

disadvantages:

- reading a single line from cache will be a little bit slower, then
before because of extra open() call to the file

summary:

- this diff presents a different caching approach which is able to
handle a lot of large files too

__future__-work:

- the code is ugly and unstructured, someone needs to beautify it
- an extra function: get_list_of_lines_from_list_of_linenumbers() would
be nice to have
- test-cases for cache-consistence would be nice to have

----------
components: Library (Lib)
files: linecache.py.diff
messages: 59041
nosy: umaxx
severity: minor
status: open
title: improvements for linecache
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file9036/linecache.py.diff

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1708>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linecache.py.diff
Type: application/octet-stream
Size: 1888 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071230/461362b8/attachment.obj 


More information about the New-bugs-announce mailing list