[Python-checkins] peps: PEP 416

victor.stinner python-checkins at python.org
Thu Mar 1 13:06:04 CET 2012


http://hg.python.org/peps/rev/1cb1bad760c6
changeset: 4102:1cb1bad760c6
user: Victor Stinner <vstinner at wyplay.com>
date: Thu Mar 01 13:06:07 2012 +0100
summary:
 PEP 416
 * Rephrase the first Rationale paragraph
 * Add 2 more use cases: cache and sandbox
 * Fix a typo
files:
 pep-0416.txt | 12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/pep-0416.txt b/pep-0416.txt
--- a/pep-0416.txt
+++ b/pep-0416.txt
@@ -19,16 +19,20 @@
 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).
+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).
 
 Use cases of frozendict:
 
+ * frozendict can be used to implement a cache
 * hashable frozendict can be used as a key of a mapping or as a member of set
 * frozendict helps optimization because the mapping is constant
 * frozendict avoids the need of a lock when the frozendict is shared
 by multiple threads or processes, especially hashable frozendict
+ * frozendict helps to implement a security sandbox with read-only objects,
+ e.g. freeze __builtins__ mapping
 
 
 Constraints
@@ -47,7 +51,7 @@
 "Py_hash_t hash;" field
 * frozendict.__hash__() is implemented using hash(frozenset(self.items())) and
 caches the result in its private hash attribute
- * Register frozendict has a collections.abc.Mapping
+ * Register frozendict as a collections.abc.Mapping
 * frozendict can be used with PyDict_GetItem(), but PyDict_SetItem() and
 PyDict_DelItem() raise a TypeError
 
-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /