[Python-Dev] Add a frozendict builtin type (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Tue Feb 28 13:17:47 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 ]
A frozendict can be used as a member of a set or as a key in a dictionary.
For example, frozendict is indirectly needed when you want to use an object as a key of a dict, whereas one attribute of this object is a dict. It isn't. You just have to define hash correctly.
Define hash on a mutable object can be surprising.
Or do you mean that you deny somehow the modification of the dict attribute, and convert the dict to a immutable object before hashing it?
frozendict helps also in threading and multiprocessing. How so?
For example, you don't need a lock to read the frozendict content, because you cannot modify the content.
Victor
- 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 ]