http://hg.python.org/peps/rev/eb2ed0fae94d changeset: 4137:eb2ed0fae94d user: Victor Stinner <victor.stinner at gmail.com> date: Wed Mar 14 23:18:49 2012 +0100 summary: PEP 416: Add links to existing implementations files: pep-0416.txt | 44 ++++++++++++++++++++++++++++++--------- 1 files changed, 34 insertions(+), 10 deletions(-) diff --git a/pep-0416.txt b/pep-0416.txt --- a/pep-0416.txt +++ b/pep-0416.txt @@ -125,6 +125,38 @@ not an issue, to avoid a copy of the dictionary. +Existing implementations +======================== + +Whitelist approach. + + * `Implementing an Immutable Dictionary (Python recipe 498072) + <http://code.activestate.com/recipes/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 + <http://pywebmail.cvs.sourceforge.net/viewvc/pywebmail/webmail/webmail/utils/ImmutableDict.py?view=markup>`_. + 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 + <https://github.com/DasIch/brownie/blob/HEAD/brownie/datastructures/mappings.py>`_. + It is hashable if keys and values are hashable. werkzeug project has the + same code: `werkzeug.datastructures.ImmutableDict + <https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/datastructures.py>`_. + * SQLAchemy project: `sqlachemy.util.immutabledict + <http://hg.sqlalchemy.org/sqlalchemy/file/tip/lib/sqlalchemy/util/_collections.py>`_. + It is not hashable and has an extra method: union(). + * `Frozen dictionaries (Python recipe 414283) <http://code.activestate.com/recipes/414283/>`_ + by Oren Tirosh. It is hashable if keys and values are hashable. + + Links ===== @@ -133,16 +165,8 @@ * PEP 412: Key-Sharing Dictionary (`issue #13903 <http://bugs.python.org/issue13903>`_) * PEP 351: The freeze protocol - * `The case for immutable dictionaries; and the central misunderstanding of PEP 351 <http://www.cs.toronto.edu/~tijmen/programming/immutableDictionaries.html>`_ - * `Frozen dictionaries (Python recipe 414283) <http://code.activestate.com/recipes/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) <http://code.activestate.com/recipes/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 <http://www.cs.toronto.edu/~tijmen/programming/immutableDictionaries.html>`_ * `make dictproxy object via ctypes.pythonapi and type() (Python recipe 576540) <http://code.activestate.com/recipes/576540/>`_ by Ikkei Shimomura. * Python security modules implementing read-only object proxies using a C -- Repository URL: http://hg.python.org/peps