Update sorted dict with items from `args` and `kwargs`. Overwrites existing items. Optional arguments `args` and `kwargs` may be a mapping, an iterable of pairs or keyword arguments. See :func:`SortedDict.__init__` for details. :param args: mapping or itera
(self, *args, **kwargs)
| 543 | |
| 544 | |
| 545 | def update(self, *args, **kwargs): |
| 546 | """Update sorted dict with items from `args` and `kwargs`. |
| 547 | |
| 548 | Overwrites existing items. |
| 549 | |
| 550 | Optional arguments `args` and `kwargs` may be a mapping, an iterable of |
| 551 | pairs or keyword arguments. See :func:`SortedDict.__init__` for |
| 552 | details. |
| 553 | |
| 554 | :param args: mapping or iterable of pairs |
| 555 | :param kwargs: keyword arguments mapping |
| 556 | |
| 557 | """ |
| 558 | if not self: |
| 559 | dict.update(self, *args, **kwargs) |
| 560 | self._list_update(dict.__iter__(self)) |
| 561 | return |
| 562 | |
| 563 | if not kwargs and len(args) == 1 and isinstance(args[0], dict): |
| 564 | pairs = args[0] |
| 565 | else: |
| 566 | pairs = dict(*args, **kwargs) |
| 567 | |
| 568 | if (10 * len(pairs)) > len(self): |
| 569 | dict.update(self, pairs) |
| 570 | self._list_clear() |
| 571 | self._list_update(dict.__iter__(self)) |
| 572 | else: |
| 573 | for key in pairs: |
| 574 | self._setitem(key, pairs[key]) |
| 575 | |
| 576 | _update = update |
| 577 |