Question about __getattribute__/__getattr__

Jeff Epler jepler at unpythonic.net
Tue Oct 1 15:36:34 CEST 2002


On Tue, Oct 01, 2002 at 09:23:22AM -0400, Joao Prado Maia wrote:
> A dictionary approach is not good enough for my needs, as it will 
> eventually hold too much data in memory. As I explained before, saving the 
> method return values in md5()'ed named files is the best solution I can 
> think of.

Then why not use "shelve" to store the data?  You'll have to conver
items to strings when used as keys, but the values can be arbitrary
Python objects which can survive pickling.  You can prototype now with
dicts, and make the switch when you need to.  Or, if you don't like
"shelve", you can write your own mapping class which will use the
files-with-md5()-names.

The point is that you can worry about this aspect later and use a dict
now.  You can then drop in different disk storage "back-ends" as
necessary, as long as you can make them act like a Python mapping.

Jeff




More information about the Python-list mailing list