[Python-Dev] PEP 416: Add a frozendict builtin type (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Thu Mar 1 13:23:26 CET 2012
- Previous message: [Python-Dev] PEP 416: Add a frozendict builtin type
- Next message: [Python-Dev] EuroPython 2012: Call for Proposal is Open! [Please spread the word]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] PEP 416: Add a frozendict builtin type
- Next message: [Python-Dev] EuroPython 2012: Call for Proposal is Open! [Please spread the word]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]