Dictionary or Database—Please advise

mk mrkafk at gmail.com
Fri Feb 26 19:04:27 CET 2010


Jeremy wrote:
> I have lots of data that I currently store in dictionaries.  However,
> the memory requirements are becoming a problem.  I am considering
> using a database of some sorts instead, but I have never used them
> before.  Would a database be more memory efficient than a dictionary?
> I also need platform independence without having to install a database
> and Python interface on all the platforms I'll be using.  Is there
> something built-in to Python that will allow me to do this?

Since you use dictionaries, I guess that simple store saving key:value 
will do?

If so, bsddb support built into Python will do just nicely.

bsddb is multiplatform, although I have not personally tested if a 
binary db created on one platform will be usable on another. You'd have 
to check this.

Caveat: from what some people say I gather that binary format between 
bsddb versions tends to change.

There's also ultra-cool-and-modern Tokyo Cabinet key:value store with 
Python bindings:

http://pypi.python.org/pypi/pytc/

I didn't test it, though.


Regards,
mk




More information about the Python-list mailing list