Speed up loading and free memory...
Josiah Carlson
jcarlson at nospam.uci.edu
Fri Mar 12 12:49:03 EST 2004
> files must not be modified, index file contains on one line a key and an
> offset which can be use to go directly to data file.
Keep the index in memory.
When you need to access a location that has an index in your data file:
data = open('data_file', 'rb')
data.seek(<index>)
data.read(<however much is needed>)
For most tasks, that should be fast enough. If you want to cache some
recently read data, check this cookbook entry:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252524
- Josiah
More information about the Python-list
mailing list