mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-36144: OrderedDict Union (PEP 584) (#18967)
This commit is contained in:
parent
d648ef10c5
commit
6d674a1bf4
5 changed files with 188 additions and 76 deletions
|
@ -293,6 +293,24 @@ class OrderedDict(dict):
|
|||
return dict.__eq__(self, other) and all(map(_eq, self, other))
|
||||
return dict.__eq__(self, other)
|
||||
|
||||
def __ior__(self, other):
|
||||
self.update(other)
|
||||
return self
|
||||
|
||||
def __or__(self, other):
|
||||
if not isinstance(other, dict):
|
||||
return NotImplemented
|
||||
new = self.__class__(self)
|
||||
new.update(other)
|
||||
return new
|
||||
|
||||
def __ror__(self, other):
|
||||
if not isinstance(other, dict):
|
||||
return NotImplemented
|
||||
new = self.__class__(other)
|
||||
new.update(self)
|
||||
return new
|
||||
|
||||
|
||||
try:
|
||||
from _collections import OrderedDict
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue