Skip to content

Commit 133d8c0

Browse files
authored
Merge pull request python#5 from willingc/pep-hamt-edit
Make second round of edits
2 parents cfd2ac7 + 1e397e9 commit 133d8c0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pep-0603.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ The proposed ``frozenmap`` type:
3333

3434
* implements the ``collections.abc.Mapping`` protocol,
3535
* 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.
3738

3839
These use cases illustrate why an immutable mapping is desirable:
3940

@@ -56,13 +57,11 @@ These use cases illustrate why an immutable mapping is desirable:
5657
Lastly, CPython [1]_ already contains the main portion of the C code required
5758
for the ``frozenmap`` implementation. The C code already exists to
5859
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.
6665

6766

6867
Specification
@@ -76,8 +75,8 @@ Construction
7675

7776
``frozenmap`` implements a ``dict``-like construction API:
7877

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.);
8180

8281
* ``frozenmap(**kwargs)`` creates a mapping from ``**kwargs``, e.g.
8382
``frozenmap(spam='ham', foo=42)``
@@ -108,7 +107,7 @@ way that they would for a ``dict``::
108107
assert foo.get('baz', 'missing') == 'missing'
109108

110109
assert m == m
111-
assert m != frozenmap()
110+
assert m != frozenmap() # m is not equal to an empty frozenmap
112111

113112
# etc.
114113

@@ -200,7 +199,8 @@ protocol, so all expected methods of iteration are supported::
200199
assert list(m.keys()) == ['foo']
201200
assert list(m.values()) == ['bar']
202201

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.
204204

205205
Hashing
206206
-------
@@ -222,8 +222,9 @@ Implementation
222222
==============
223223

224224
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.
227228

228229
HAMT
229230
----

0 commit comments

Comments
 (0)