File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,6 +122,36 @@ It's possible to compare ``frozendict`` to ``dict``. Example::
122122 True
123123
124124
125+ Union operators
126+ ---------------
127+
128+ It's possible to join two ``frozendict ``, or one ``frozendict `` with a
129+ ``dict ``, with the merge (``| ``) operator. Example::
130+
131+ >>> frozendict(x=1) | frozendict(y=1)
132+ frozendict({'x': 1, 'y': 1})
133+ >>> frozendict(x=1) | dict(y=1)
134+ frozendict({'x': 1, 'y': 1})
135+
136+ If some keys are in common, the values of the right operand are taken::
137+
138+ >>> frozendict(x=1, y=2) | frozendict(y=5)
139+ frozendict({'x': 1, 'y': 5})
140+
141+ The update operator `|= ` does not modify a ``frozendict `` in-place, but
142+ creates a new ``frozendict ``::
143+
144+ >>> d = frozendict(x=1)
145+ >>> copy = d
146+ >>> d |= frozendict(y=2)
147+ >>> d
148+ frozendict({'x': 1, 'y': 2})
149+ >>> copy # left unchanged
150+ frozendict({'x': 1})
151+
152+ See also :pep: `584 ` "Add Union Operators To dict".
153+
154+
125155Typing
126156------
127157
You can’t perform that action at this time.
0 commit comments