Movatterモバイル変換
[0]ホーム
[Python-Dev] Add a frozendict builtin type
Victor Stinnervictor.stinner at haypocalc.com
Tue Feb 28 13:17:47 CET 2012
>> 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 dictattribute, and convert the dict to a immutable object before hashingit?>> 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
More information about the Python-Devmailing list
[8]ページ先頭