Fixed keys() mapping

2007-01-11 Thread George Sakkis
I wrote an 'fkdict' dict-like class for mappings with a fixed set of keys but I'm wondering if there's a simpler way to go about it. First off, the main motivation for it is to save memory in case of many dicts with the same keys, for example when reading from a csv.DictReader or constructing

Re: Fixed keys() mapping

2007-01-11 Thread Neil Cerutti
On 2007-01-11, George Sakkis [EMAIL PROTECTED] wrote: I wrote an 'fkdict' dict-like class for mappings with a fixed set of keys but I'm wondering if there's a simpler way to go about it. First off, the main motivation for it is to save memory in case of many dicts with the same keys, for

Re: Fixed keys() mapping

2007-01-11 Thread Gabriel Genellina
At Thursday 11/1/2007 14:19, George Sakkis wrote: The implementation I came up with goes like this: each fkdict instance stores only the values as a list in self._values. The keys and the mapping of keys to indices are stored in a dynamically generated subclass of fkdict, so that self._keys and

Re: Fixed keys() mapping

2007-01-11 Thread George Sakkis
For what it's worth, I added it to the Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499373 George -- http://mail.python.org/mailman/listinfo/python-list