It never fails (bsddb retirement in 2.3)

Bengt Richter bokr at oz.net
Thu May 1 17:10:59 EDT 2003


On 01 May 2003 14:00:21 -0400, Nick Vargish <nav at adams.patriot.net> wrote:

>
>So I'm trying to get Python accepted here at work (a large US
>government office). One of my tasks is to rewrite a number of legacy C
>programs in a language largely of my choice. I have my supervisor on
>board with the idea of Python, and he's even looking into us taking
>classes from ActiveState or PythonLabs or whoever offers such
>things...
>
>A number of these old programs rely on a large text file to determine
>where to go for more information. They do a linear line-based search
>in this 750Kb file. They do this every time someone asks the server
>for a document.
>
Just out of curiosity, what criteria are used to select a line, and
how do you use it? If the lookup is by a simple key or two, you could
conceivably index the data in the big file when it changes, and just
have a dict of keys to binary seek positions and lengths for the data,
and read (or access via memorymapped file and slice) the data only after
lookup of keys. That way, the dict would be smaller, and could
be pickled and loaded pretty fast. If the lines all end in '\n or \r\n'
(or unique delimiter) and have a max size, you wouldn't have to store
lengths in the dict.

Just a thought, for possibly avoiding a data base package pers se.
Python dicts are pretty quick.

Be happy ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list