Dictionary or Database—Please advise

Patrick Sabin patrick.just4fun at gmail.com
Fri Feb 26 15:56:47 EST 2010


> Shelve looks like an interesting option, but what might pose an issue
> is that I'm reading the data from a disk instead of memory.  I didn't
> mention this in my original post, but I was hoping that by using a
> database it would be more memory efficient in storing data in RAM so I
> wouldn't have to read from (or swap to/from) disk.

A database usually stores data on disk and not in RAM. However you could 
use sqlite with :memory:, so that it runs in RAM.

> Would using the
> shelve package make reading/writing data from disk faster since it is
> in a binary format?
> 
Faster than what? Shelve uses caching, so it is likely to be faster than 
a self-made solution. However, accessing disk is much slower than 
accessing RAM.

> Jeremy
- Patrick



More information about the Python-list mailing list