randomly write to a file

Alex Martelli aleax at mac.com
Mon May 7 23:41:11 EDT 2007


Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:
   ...
> Hang on, as I understand it, Nick just suggesting using SQlite for 
> holding indexes into the file! That's why I said it was overkill. So 
> whether the indexes are in a list or a database, you've _still_ got to
> deal with writing to the file.
> 
> If I've misunderstood Nick's suggestion, if he actually meant to read the
> entire text file into the database, well, that's just a heavier version
> of reading the file into a list of strings, isn't it? If the database
> gives you more and/or better functionality than file.readlines(), then I
> have no problem with using the right tool for the job.

Ah well, I may have misunderstood myself.  I'd keep the whole thing in
an SQlite table, definitely NOT a table + an external file -- no, that's
not going to be heavier than reading things in memory, SQLite is smarter
than one might think:-).  Obviously, I'm assuming that one's dealing
with an amount of data that doesn't just comfortably and easily fit in
memory, or at least one that gives pause at the thought of sucking it
all into memory and writing it back out again at every program run.


Alex



More information about the Python-list mailing list