[Python-Dev] Add a frozendict builtin type
Nick Coghlan
ncoghlan at gmail.com
Thu Mar 1 14:34:56 CET 2012
More information about the Python-Dev mailing list
Thu Mar 1 14:34:56 CET 2012
- Previous message: [Python-Dev] Add a frozendict builtin type
- Next message: [Python-Dev] Add a frozendict builtin type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Mar 1, 2012 at 7:29 PM, André Malo <nd at perlig.de> wrote: > - Caching. My data container objects (say, resultsets from a db or something) > usually inherit from list or dict (sometimes also set) and are cached > heavily. In order to ensure that they are not modified (accidentially), I > have to choices: deepcopy or immutability. deepcopy is so expensive, that > it's often cheaper to just leave out the cache. So I use immutability. (oh > well, the objects are further restricted with __slots__) Speaking of caching - functools.lru_cache currently has to do a fair bit of work in order to correctly cache keyword arguments. It's obviously a *solvable* problem even without frozendict in the collections module (it just stores the dict contents as a sorted tuple of 2-tuples), but it would still be interesting to compare the readability, speed and memory consumption differences of a version of lru_cache that used frozendict to cache the keyword arguments instead. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Add a frozendict builtin type
- Next message: [Python-Dev] Add a frozendict builtin type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list