list comprehension help

rkmr.em at rkmr.em at
Sun Mar 18 17:53:14 CET 2007

On 3/18/07, Marc 'BlackJack' Rintsch <bj_666 at> wrote:
> In <mailman.5248.1174235057.32031.python-list at>, Daniel Nogradi
> wrote:
> >> f = open('file.txt','r')
> >> for line in f:
> >>         db[line.split(' ')[0]] = line.split(' ')[-1]
> >>         db.sync()
> >
> > What is db here? Looks like a dictionary but that doesn't have a sync method.
> Shelves (`shelve` module) have this API.  And syncing forces the changes
> to be written to disks, so all caching and buffering of the operating
> system is prevented.  So this may slow down the program considerably.

It is a handle for bsddb

import bsddb
Syncing will defenitely slow down. I will slow that down. But is there
any improvement I can do to the other part the splitting and setting
the key value/pair?

More information about the Python-list mailing list