Re: [Python-Dev] Add a frozendict builtin type

2012年3月01日 05:36:56 -0800

On Thu, Mar 1, 2012 at 7:29 PM, André Malo <[email protected]> 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  |  [email protected]  |  Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to