@@ -33,7 +33,8 @@ The proposed ``frozenmap`` type:
33
33
34
34
* implements the ``collections.abc.Mapping `` protocol,
35
35
* supports pickling, and
36
- * provides an API for efficient mutation.
36
+ * provides an API for mutation which uses efficient creation and manipulation
37
+ of a new mutable copy of the immutable instance.
37
38
38
39
These use cases illustrate why an immutable mapping is desirable:
39
40
@@ -56,13 +57,11 @@ These use cases illustrate why an immutable mapping is desirable:
56
57
Lastly, CPython [1 ]_ already contains the main portion of the C code required
57
58
for the ``frozenmap `` implementation. The C code already exists to
58
59
implement the ``contextvars `` module (see :pep: `567 ` for more details.)
59
-
60
- [TODO: Additional explanation needed here]
61
- Exposing that code via a public collection type drastically
62
- increases the number of users of that code. That helps with
63
- discovering bugs and improving performance which otherwise would
64
- be very challenging because most programs use ``contextvars ``
65
- indirectly.
60
+ Exposing this C code via a public collection type drastically
61
+ increases the number of users of the code. This leads to increased code
62
+ quality by discovering bugs and improving performance which without a
63
+ ``frozenset `` collection would be very challenging because most programs use
64
+ the ``contextvars `` module indirectly.
66
65
67
66
68
67
Specification
@@ -76,8 +75,8 @@ Construction
76
75
77
76
``frozenmap `` implements a ``dict ``-like construction API:
78
77
79
- * ``frozenmap() `` creates a new empty mapping (TODO: clarify...immutable after the first
80
- write of data??? );
78
+ * ``frozenmap() `` creates a new empty mapping (which can be populated with
79
+ data using the `` set `` method. );
81
80
82
81
* ``frozenmap(**kwargs) `` creates a mapping from ``**kwargs ``, e.g.
83
82
``frozenmap(spam='ham', foo=42) ``
@@ -108,7 +107,7 @@ way that they would for a ``dict``::
108
107
assert foo.get('baz', 'missing') == 'missing'
109
108
110
109
assert m == m
111
- assert m != frozenmap()
110
+ assert m != frozenmap() # m is not equal to an empty frozenmap
112
111
113
112
# etc.
114
113
@@ -200,7 +199,8 @@ protocol, so all expected methods of iteration are supported::
200
199
assert list(m.keys()) == ['foo']
201
200
assert list(m.values()) == ['bar']
202
201
203
- Iteration, unlike in ``dict ``, does not preserve the insertion order.
202
+ Iteration in ``frozenmap ``, unlike in ``dict ``, does not preserve the
203
+ insertion order.
204
204
205
205
Hashing
206
206
-------
@@ -222,8 +222,9 @@ Implementation
222
222
==============
223
223
224
224
The proposed ``frozenmap `` immutable type uses a Hash Array Mapped Trie (HAMT)
225
- data structure. Functional programming languages, like Clojure, use this novel
226
- data structure to efficiently implement immutable hash tables.
225
+ data structure. Functional programming languages, like Clojure, use this novel,
226
+ yet often implemented, data structure to efficiently implement immutable hash
227
+ tables.
227
228
228
229
HAMT
229
230
----
0 commit comments