Convert of dictionary with integer keys to a switch statement.
431579
def dict_to_switch(d):
    """"""
    def lookup(query):
        return d[query]
    lookup._always_inline_ = True
    unrolling_items = unrolling_iterable(d.items())
    return lookup
253093
def nsorted(
    to_sort: Iterable[str],
    key: Optional[Callable[[str], Any]] = None
) -> List[str]:
    """"""
    if key is None:
        key_callback = _natural_keys
    else:
        def key_callback(text: str) -> List[Any]:
            return _natural_keys(key(text))  # type: ignore

    return sorted(to_sort, key=key_callback)
1369256
private static final void swap(int[] keys, Object[][] values, int i, int j) {
    int keySwap = keys[i];
    keys[i] = keys[j];
    keys[j] = keySwap;

    Object swapValue;
    for (int k = 0; k < values.length; k++) {
      swapValue = values[k][i];
      values[k][i] = values[k][j];
      values[k][j] = swapValue;
    }
  }
721867
def make_native_dict_keys(d):
    """"""
    res = {}
    for k, v in d.items():  #
        k = compat.to_native(k)
        if type(v) is dict:
            v = make_native_dict_keys(v)
        res[k] = v
    return res
370872
private void sawSwitch(int pc) {
        int[] offsets = getSwitchOffsets();
        List<Integer> targets = new ArrayList<>(offsets.length);
        for (int offset : offsets) {
            targets.add(Integer.valueOf(offset + pc));
        }
        Integer defOffset = Integer.valueOf(getDefaultSwitchOffset() + pc);
        if (!targets.contains(defOffset)) {
            targets.add(defOffset);
        }
        Collections.sort(targets);

        Integer lastTarget = targets.get(0);
        for (int i = 1; i < targets.size(); i++) {
            Integer nextTarget = targets.get(i);
            ScopeBlock sb = new ScopeBlock(lastTarget.intValue(), nextTarget.intValue());
            sb.setCase();
            rootScopeBlock.addChild(sb);
            lastTarget = nextTarget;
        }
        for (Integer target : targets) {
            switchTargets.set(target.intValue());
        }
    }
1097556
def invert_dict(d):
    """"""
    # Based on recipe from ASPN
    result = {}
    for k, v in d.items():
        keys = result.setdefault(v, [])
        keys.append(k)
    return result
404270
def cast(keys, data):
        """"""
        matrix = Matrix()
        matrix.keys = keys
        matrix.data = data
        return matrix
173541
def invert_dict(invertible_dict):
    """"""
    inverted = {}
    for k, v in six.iteritems(invertible_dict):
        if not isinstance(v, Hashable):
            raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(
                k, type(v).__name__))
        if v in inverted:
            raise TypeError(u'Expected an invertible dict, but keys '
                            u'{} and {} map to the same value'.format(
                                inverted[v], k))
        inverted[v] = k
    return inverted
510430
def _input_to_dict(i, records, remapped=None):
    
    if not remapped: remapped = {}
    var_type, records = _to_variable_type(i["type"], records)
    if var_type.startswith("Array") and "inputBinding" in i.get("type", {}):
        ib = i["type"]["inputBinding"]
    elif "inputBinding" in i:
        ib = i["inputBinding"]
    else:
        ib = {"prefix": None, "itemSeparator": ";;", "position": None}
    name = _id_to_localname(i["id"]) if "id" in i else i["name"]
    return {"name": remapped.get(name) or name,
            "variable_type": var_type,
            "prefix": ib["prefix"], "separator": ib["itemSeparator"],
            "position": ib["position"], "is_required": True,
            "default": i.get("default", None), "separate": ib.get("separate", True)}, records
896779
function fnInvertKeyValues( aIn )
{
	var aRet=[];
	for ( var i=0, iLen=aIn.length ; i<iLen ; i++ )
	{
		aRet[ aIn[i] ] = i;
	}
	return aRet;
}
572486
def convert_dict_to_option_dict(input_dict):
    """"""
    ret_dict = {}
    for key, value in input_dict.items():
        ret_dict[key] = convert_value_to_option_tuple(value)
    return ret_dict
404217
def _convert_entry(self, entry):
        """"""
        result = {}
        for key, value in entry.items():
            if isinstance(value, list):
                result[key] = [self._convert_field(key, val) for val in value]
            else:
                result[key] = self._convert_field(key, value)
        return result
572265
def valuesToDict(key):
    """"""
    d = {}
    size = _winreg.QueryInfoKey(key)[1]
    for i in xrange(size):
        d[_winreg.EnumValue(key, i)[0]] = _winreg.EnumValue(key, i)[1]
    return d
60071
def key_expand(key, Nk=4):
    """"""
    assert Nk in {4, 6, 8}
    Nr = Nk + 6

    key = key.reshape(Nk, 32)
    rkey = exprzeros(4*(Nr+1), 32)

    for i in range(Nk):
        rkey[i] = key[i]

    for i in range(Nk, 4*(Nr+1)):
        if i % Nk == 0:
            rkey[i] = rkey[i-Nk] ^ subword(rotword(rkey[i-1])) ^ RCON[i//Nk].zext(32-8)
        elif Nk > 6 and i % Nk == 4:
            rkey[i] = rkey[i-Nk] ^ subword(rkey[i-1])
        else:
            rkey[i] = rkey[i-Nk] ^ rkey[i-1]

    return rkey
96614
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True):
        """"""
        if not isinstance(dictionary, Mapping):
            raise TypeError('dictionary should be mapping')
        obj = cls(values, value_filter)
        values = obj.__values
        for name, value in dictionary.items():
            if not isinstance(name, string_types):
                raise TypeError('Key %s is not a string' % str(name))
            setattr(values, name, value)
        if obj.missing and not allow_unset:
            raise ValueError('%d value(s) are unset' % len(obj.missing))
        return obj
476685
def _convert_choices(self, choices):
        """"""

        final_choices = []
        for choice in choices:

            if isinstance(choice, ChoiceEntry):
                final_choices.append(choice)
                continue

            original_choice = choice
            choice = list(choice)
            length = len(choice)

            assert 2 <= length <= 4, 'Invalid number of entries in %s' % (original_choice,)

            final_choice = []

            # do we have attributes?
            if length > 2 and isinstance(choice[-1], Mapping):
                final_choice.append(choice.pop())
            elif length == 4:
                attributes = choice.pop()
                assert attributes is None or isinstance(attributes, Mapping), 'Last argument must be a dict-like object in %s' % (original_choice,)
                if attributes:
                    final_choice.append(attributes)

            # the constant
            final_choice.insert(0, choice.pop(0))

            # the db value
            final_choice.insert(1, choice.pop(0))

            if len(choice):
                # we were given a display value
                final_choice.insert(2, choice.pop(0))
            else:
                # no display value, we compute it from the constant
                final_choice.insert(2, self.display_transform(final_choice[0]))

            final_choices.append(final_choice)

        return super(AutoDisplayChoices, self)._convert_choices(final_choices)
921531
def nsorted(to_sort, key=None):
    """"""
    if key is None:
        key_callback = _natural_keys
    else:
        def key_callback(item):
            return _natural_keys(key(item))

    return sorted(to_sort, key=key_callback)