[Python-Dev] PEP 416: Add a frozendict builtin type

Victor Stinner victor.stinner at gmail.com
Thu Mar 1 13:08:19 CET 2012


>> Rationale
>> =========
>>
>> A frozendict mapping cannot be changed, but its values can be mutable
>> (not hashable). A frozendict is hashable and so immutable if all
>> values are hashable (immutable).
> The wording of the above seems very unclear to me.
>
> Do you mean "A frozendict has a constant set of keys, and for every key,
> d[key] has a specific value for the lifetime of the frozendict.
> However, these values *may* be mutable.  The frozendict is hashable iff
> all of the values are hashable." ?  (or somesuch)

New try:

"A frozendict is a read-only mapping: a key cannot be added nor
removed, and a key is always mapped to the same value. However,
frozendict values can be mutable (not hashable). A frozendict is
hashable and so immutable if and only if all values are hashable
(immutable)."

>>  * Register frozendict has a collections.abc.Mapping
> s/has/as/ ?

Oops, fixed.

>> If frozendict is used to harden Python (security purpose), it must be
>> implemented in C. A type implemented in C is also faster.
>
> You mention security purposes here, but this isn't mentioned in the
> Rationale or Use Cases

I added two use cases: security sandbox and cache.

> Hope this is helpful

Yes, thanks.

Victor


More information about the Python-Dev mailing list