From 0b2f139d85863bedade23ab51231a984b4bd00c3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 14 Mar 2012 23:18:49 +0100 Subject: [PATCH] PEP 416: Add links to existing implementations --- pep-0416.txt | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/pep-0416.txt b/pep-0416.txt index ef32a90f4..3362fa985 100644 --- a/pep-0416.txt +++ b/pep-0416.txt @@ -125,6 +125,38 @@ However dictproxy can be useful in some cases, where its mutable property is not an issue, to avoid a copy of the dictionary. +Existing implementations +======================== + +Whitelist approach. + + * `Implementing an Immutable Dictionary (Python recipe 498072) + `_ by Aristotelis Mikropoulos. + Similar to frozendict except that it is not truly read-only: it is possible + to access to this private internal dict. It does not implement __hash__ and + has an implementation issue: it is possible to call again __init__() to + modify the mapping. + * PyWebmail contains an ImmutableDict type: `webmail.utils.ImmutableDict + `_. + It is hashable if keys and values are hashable. It is not truly read-only: + its internal dict is a public attribute. + +Blacklist approach: inherit from dict and override write methods to raise an +exception. It is not truly read-only: it is still possible to call dict methods +on such "frozen dictionary" to modify it. + + * brownie: `brownie.datastructures.ImmuatableDict + `_. + It is hashable if keys and values are hashable. werkzeug project has the + same code: `werkzeug.datastructures.ImmutableDict + `_. + * SQLAchemy project: `sqlachemy.util.immutabledict + `_. + It is not hashable and has an extra method: union(). + * `Frozen dictionaries (Python recipe 414283) `_ + by Oren Tirosh. It is hashable if keys and values are hashable. + + Links ===== @@ -133,16 +165,8 @@ Links * PEP 412: Key-Sharing Dictionary (`issue #13903 `_) * PEP 351: The freeze protocol - * `The case for immutable dictionaries; and the central misunderstanding of PEP 351 `_ - * `Frozen dictionaries (Python recipe 414283) `_ - by Oren Tirosh. Blacklist approach: inherit from dict and override write - methods to raise an exception. It is not truly read-only: it is still - possible to call dict methods on such "frozen dictionary" to modify it. - * `Implementing an Immutable Dictionary (Python recipe 498072) `_ - by Aristotelis Mikropoulos. Similar to frozendict except that it is not - truly read-only. It is possible to access to this private internal dict. - It does not implement __hash__ and has an implementation issue: it is - possible to call again __init__() to modify the mapping. + * `The case for immutable dictionaries; and the central misunderstanding of + PEP 351 `_ * `make dictproxy object via ctypes.pythonapi and type() (Python recipe 576540) `_ by Ikkei Shimomura. * Python security modules implementing read-only object proxies using a C