Database in a simple ascii file

Don Arnold darnold02 at sprynet.com
Fri Nov 30 19:42:13 EST 2001


On 30-Nov-2001, Lucio Torre <lucio at movilogic.com> wrote:

> Steve Holden wrote:
>
> >"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/
> >
>
> I think that ZODB will allow you to have a dictionary bigger than your
> memory. Is that so? Anyone tried it?

Can't you accomplish this using the shelve module, more or less?



More information about the Python-list mailing list