Database in a simple ascii file

Steve Holden sholden at holdenweb.com
Wed Nov 28 08:29:52 EST 2001


"Rafael Mentz Aquino" <pythonlist at zumnet.com.br> wrote ...
> Hi,
>
> How many lines can I have in a simple ascii file before
> I start to loose performance when I open this file and
> put all the lines in a dict, turning the first column into the key
> and the rest of the line into a list associated to that key.
>
> (my file has just 100 lines, but that question starts to bother me ;-)
>
You couls always do some testing ...

In fact this is probably the fastest way to do it, for random keys and a
file that will fit comfortably into memory. The dictionary implementation
works hard to make sure that access time is roughly constant no matter what
the size.

Posters have in the past reported using dictionaries of 100,000 elements
without problems, so your file has to grow some before you hit uncharted
territory...

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list