class_docstr: Sorted dict is a sorted mutable mapping.
  
  Sorted dict keys are maintained in sorted order. The design of sorted dict
  is simple: sorted dict inherits from dict to store items and maintains a
  sorted list of keys.
  
  Sorted dict keys must be hashable and comparable. The hash and total
  ordering of keys must not change while they are stored in the sorted dict.
  
  Mutable mapping methods:
  
  * :func:`SortedDict.__getitem__` (inherited from dict)
  * :func:`SortedDict.__setitem__`
  * :func:`SortedDict.__delitem__`
  * :func:`SortedDict.__iter__`
  * :func:`SortedDict.__len__` (inherited from dict)
  
  Methods for adding items:
  
  * :func:`SortedDict.setdefault`
  * :func:`SortedDict.update`
  
  Methods for removing items:
  
  * :func:`SortedDict.clear`
  * :func:`SortedDict.pop`
  * :func:`SortedDict.popitem`
  
  Methods for looking up items:
  
  * :func:`SortedDict.__contains__` (inherited from dict)
  * :func:`SortedDict.get` (inherited from dict)
  * :func:`SortedDict.peekitem`
  
  Methods for views:
  
  * :func:`SortedDict.keys`
  * :func:`SortedDict.items`
  * :func:`SortedDict.values`
  
  Methods for miscellany:
  
  * :func:`SortedDict.copy`
  * :func:`SortedDict.fromkeys`
  * :func:`SortedDict.__reversed__`
  * :func:`SortedDict.__eq__` (inherited from dict)
  * :func:`SortedDict.__ne__` (inherited from dict)
  * :func:`SortedDict.__repr__`
  * :func:`SortedDict._check`
  
  Sorted list methods available (applies to keys):
  
  * :func:`SortedList.bisect_left`
  * :func:`SortedList.bisect_right`
  * :func:`SortedList.count`
  * :func:`SortedList.index`
  * :func:`SortedList.irange`
  * :func:`SortedList.islice`
  * :func:`SortedList._reset`
  
  Additional sorted list methods available, if key-function used:
  
  * :func:`SortedKeyList.bisect_key_left`
  * :func:`SortedKeyList.bisect_key_right`
  * :func:`SortedKeyList.irange_key`
  
  Sorted dicts may only be compared for equality and inequality.
class_docstr_tok: ["Sorted","dict","is","a","sorted","mutable","mapping",".","Sorted","dict","keys","are","maintained","in","sorted","order",".","The","design","of","sorted","dict","is","simple",":","sorted","dict","inherits","from","dict","to","store","items","and","maintains","a","sorted","list","of","keys",".","Sorted","dict","keys","must","be","hashable","and","comparable",".","The","hash","and","total","ordering","of","keys","must","not","change","while","they","are","stored","in","the","sorted","dict",".","Mutable","mapping","methods",":","*",":","func",":","`","SortedDict.__getitem__","`","(","inherited","from","dict",")","*",":","func",":","`","SortedDict.__setitem__","`","*",":","func",":","`","SortedDict.__delitem__","`","*",":","func",":","`","SortedDict.__iter__","`","*",":","func",":","`","SortedDict.__len__","`","(","inherited","from","dict",")","Methods","for","adding","items",":","*",":","func",":","`","SortedDict.setdefault","`","*",":","func",":","`","SortedDict.update","`","Methods","for","removing","items",":","*",":","func",":","`","SortedDict.clear","`","*",":","func",":","`","SortedDict.pop","`","*",":","func",":","`","SortedDict.popitem","`","Methods","for","looking","up","items",":","*",":","func",":","`","SortedDict.__contains__","`","(","inherited","from","dict",")","*",":","func",":","`","SortedDict.get","`","(","inherited","from","dict",")","*",":","func",":","`","SortedDict.peekitem","`","Methods","for","views",":","*",":","func",":","`","SortedDict.keys","`","*",":","func",":","`","SortedDict.items","`","*",":","func",":","`","SortedDict.values","`","Methods","for","miscellany",":","*",":","func",":","`","SortedDict.copy","`","*",":","func",":","`","SortedDict.fromkeys","`","*",":","func",":","`","SortedDict.__reversed__","`","*",":","func",":","`","SortedDict.__eq__","`","(","inherited","from","dict",")","*",":","func",":","`","SortedDict.__ne__","`","(","inherited","from","dict",")","*",":","func",":","`","SortedDict.__repr__","`","*",":","func",":","`","SortedDict._check","`","Sorted","list","methods","available","(","applies","to","keys",")",":","*",":","func",":","`","SortedList.bisect_left","`","*",":","func",":","`","SortedList.bisect_right","`","*",":","func",":","`","SortedList.count","`","*",":","func",":","`","SortedList.index","`","*",":","func",":","`","SortedList.irange","`","*",":","func",":","`","SortedList.islice","`","*",":","func",":","`","SortedList._reset","`","Additional","sorted","list","methods","available",",","if","key-function","used",":","*",":","func",":","`","SortedKeyList.bisect_key_left","`","*",":","func",":","`","SortedKeyList.bisect_key_right","`","*",":","func",":","`","SortedKeyList.irange_key","`","Sorted","dicts","may","only","be","compared","for","equality","and","inequality","."]
docstr: Initialize sorted dict instance.
  
  Optional key-function argument defines a callable that, like the `key`
  argument to the built-in `sorted` function, extracts a comparison key
  from each dictionary key. If no function is specified, the default
  compares the dictionary keys directly. The key-function argument must
  be provided as a positional argument and must come before all other
  arguments.
  
  Optional iterable argument provides an initial sequence of pairs to
  initialize the sorted dict. Each pair in the sequence defines the key
  and corresponding value. If a key is seen more than once, the last
  value associated with it is stored in the new sorted dict.
  
  Optional mapping argument provides an initial mapping of items to
  initialize the sorted dict.
  
  If keyword arguments are given, the keywords themselves, with their
  associated values, are added as items to the dictionary. If a key is
  specified both in the positional argument and as a keyword argument,
  the value associated with the keyword is stored in the
  sorted dict.
  
  Sorted dict keys must be hashable, per the requirement for Python's
  dictionaries. Keys (or the result of the key-function) must also be
  comparable, per the requirement for sorted lists.
  
  >>> d = {'alpha': 1, 'beta': 2}
  >>> SortedDict([('alpha', 1), ('beta', 2)]) == d
  True
  >>> SortedDict({'alpha': 1, 'beta': 2}) == d
  True
  >>> SortedDict(alpha=1, beta=2) == d
  True
docstr_tok: ["Initialize","sorted","dict","instance",".","Optional","key-function","argument","defines","a","callable","that",",","like","the","`","key","`","argument","to","the","built-in","`","sorted","`","function",",","extracts","a","comparison","key","from","each","dictionary","key",".","If","no","function","is","specified",",","the","default","compares","the","dictionary","keys","directly",".","The","key-function","argument","must","be","provided","as","a","positional","argument","and","must","come","before","all","other","arguments",".","Optional","iterable","argument","provides","an","initial","sequence","of","pairs","to","initialize","the","sorted","dict",".","Each","pair","in","the","sequence","defines","the","key","and","corresponding","value",".","If","a","key","is","seen","more","than","once",",","the","last","value","associated","with","it","is","stored","in","the","new","sorted","dict",".","Optional","mapping","argument","provides","an","initial","mapping","of","items","to","initialize","the","sorted","dict",".","If","keyword","arguments","are","given",",","the","keywords","themselves",",","with","their","associated","values",",","are","added","as","items","to","the","dictionary",".","If","a","key","is","specified","both","in","the","positional","argument","and","as","a","keyword","argument",",","the","value","associated","with","the","keyword","is","stored","in","the","sorted","dict",".","Sorted","dict","keys","must","be","hashable",",","per","the","requirement","for","Python's","dictionaries",".","Keys","(","or","the","result","of","the","key-function",")","must","also","be","comparable",",","per","the","requirement","for","sorted","lists",".",">",">",">","d","=","{","'alpha","'",":","1",",","'beta","'",":","2","}",">",">",">","SortedDict","(","[","(","'alpha","'",",","1",")",",","(","'beta","'",",","2",")","]",")","==","d","True",">",">",">","SortedDict","(","{","'alpha","'",":","1",",","'beta","'",":","2","}",")","==","d","True",">",">",">","SortedDict","(","alpha=1",",","beta=2",")","==","d","True"]
code: def __init__(self, *args, **kwargs):
      """Initialize sorted dict instance.
  
      Optional key-function argument defines a callable that, like the `key`
      argument to the built-in `sorted` function, extracts a comparison key
      from each dictionary key. If no function is specified, the default
      compares the dictionary keys directly. The key-function argument must
      be provided as a positional argument and must come before all other
      arguments.
  
      Optional iterable argument provides an initial sequence of pairs to
      initialize the sorted dict. Each pair in the sequence defines the key
      and corresponding value. If a key is seen more than once, the last
      value associated with it is stored in the new sorted dict.
  
      Optional mapping argument provides an initial mapping of items to
      initialize the sorted dict.
  
      If keyword arguments are given, the keywords themselves, with their
      associated values, are added as items to the dictionary. If a key is
      specified both in the positional argument and as a keyword argument,
      the value associated with the keyword is stored in the
      sorted dict.
  
      Sorted dict keys must be hashable, per the requirement for Python's
      dictionaries. Keys (or the result of the key-function) must also be
      comparable, per the requirement for sorted lists.
  
      >>> d = {'alpha': 1, 'beta': 2}
      >>> SortedDict([('alpha', 1), ('beta', 2)]) == d
      True
      >>> SortedDict({'alpha': 1, 'beta': 2}) == d
      True
      >>> SortedDict(alpha=1, beta=2) == d
      True
  
      """
      if args and (args[0] is None or callable(args[0])):
          _key = self._key = args[0]
          args = args[1:]
      else:
          _key = self._key = None
  
      self._list = SortedList(key=_key)
  
      # Reaching through ``self._list`` repeatedly adds unnecessary overhead
      # so cache references to sorted list methods.
  
      _list = self._list
      self._list_add = _list.add
      self._list_clear = _list.clear
      self._list_iter = _list.__iter__
      self._list_reversed = _list.__reversed__
      self._list_pop = _list.pop
      self._list_remove = _list.remove
      self._list_update = _list.update
  
      # Expose some sorted list methods publicly.
  
      self.bisect_left = _list.bisect_left
      self.bisect = _list.bisect_right
      self.bisect_right = _list.bisect_right
      self.index = _list.index
      self.irange = _list.irange
      self.islice = _list.islice
      self._reset = _list._reset
  
      if _key is not None:
          self.bisect_key_left = _list.bisect_key_left
          self.bisect_key_right = _list.bisect_key_right
          self.bisect_key = _list.bisect_key
          self.irange_key = _list.irange_key
  
      self._update(*args, **kwargs)
  
imports: import sys
  import warnings
  from itertools import chain
  from .sortedlist import SortedList, recursive_repr
  from .sortedset import SortedSet
label_desc: Use image node_id 1 to create a new SortedDict object from inherited base classes: dict with example: obj = SortedDict()