how to build a dict including a large number of data

Fredrik Lundh fredrik at
Fri Jan 4 15:17:22 CET 2008

wanzathe wrote:

> i have a binary file named test.dat including 9600000 records.
> the record format is int a + int b + int c + int d
> i want to build a dict like this: key=int a,int b  values=int c,int d
> i choose using bsddb and it takes about 140 seconds to build the dict.

you're not building a dict, you're populating a persistent database. 
storing ~70000 records per second isn't that bad, really...

> what can i do if i want to make my program run faster?
> or is there another way i can choose?

why not just use a real Python dictionary, and the marshal module for 


More information about the Python-list mailing list