PEP 416: Add links to existing implementations
This commit is contained in:
parent
9398b82d3a
commit
0b2f139d85
44
pep-0416.txt
44
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.
|
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
|
Links
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
@ -133,16 +165,8 @@ Links
|
||||||
* PEP 412: Key-Sharing Dictionary
|
* PEP 412: Key-Sharing Dictionary
|
||||||
(`issue #13903 <http://bugs.python.org/issue13903>`_)
|
(`issue #13903 <http://bugs.python.org/issue13903>`_)
|
||||||
* PEP 351: The freeze protocol
|
* 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>`_
|
* `The case for immutable dictionaries; and the central misunderstanding of
|
||||||
* `Frozen dictionaries (Python recipe 414283) <http://code.activestate.com/recipes/414283/>`_
|
PEP 351 <http://www.cs.toronto.edu/~tijmen/programming/immutableDictionaries.html>`_
|
||||||
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.
|
|
||||||
* `make dictproxy object via ctypes.pythonapi and type() (Python recipe
|
* `make dictproxy object via ctypes.pythonapi and type() (Python recipe
|
||||||
576540) <http://code.activestate.com/recipes/576540/>`_ by Ikkei Shimomura.
|
576540) <http://code.activestate.com/recipes/576540/>`_ by Ikkei Shimomura.
|
||||||
* Python security modules implementing read-only object proxies using a C
|
* Python security modules implementing read-only object proxies using a C
|
||||||
|
|
Loading…
Reference in New Issue