This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author umaxx
Recipients umaxx
Date 2007-12-30.14:18:35
SpamBayes Score 0.02290279
Marked as misclassified No
Message-id <1199024318.28.0.602984080184.issue1708@psf.upfronthosting.co.za>
In-reply-to
Content
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
Files
File name Uploaded
linecache.py.diff umaxx, 2007-12-30.14:18:36
History
Date User Action Args
2007-12-30 14:18:38umaxxsetspambayes_score: 0.0229028 -> 0.02290279
recipients: + umaxx
2007-12-30 14:18:38umaxxsetspambayes_score: 0.0229028 -> 0.0229028
messageid: <1199024318.28.0.602984080184.issue1708@psf.upfronthosting.co.za>
2007-12-30 14:18:38umaxxlinkissue1708 messages
2007-12-30 14:18:37umaxxcreate