def list_switch_factory(get_default_case, keys_to_cases, length=1000):
    """
    Factory to create fast integer-only-based switches (using list-indexing).

    A usefule example of the optional 'custom_switch_factory' attribute value.
    """
    default_case = get_default_case()
    switch = [keys_to_cases.pop(key, default_case) for key in xrange(length)]
    if keys_to_cases:
        raise ValueError(
            'declared list length is too small for keys: ' +
            ', '.join(map(repr, sorted(keys_to_cases))))
    return switch

    Factory to create fast integer-only-based switches (using list-indexing).

    A usefule example of the optional 'custom_switch_factory' attribute value.
    
recipes/Python/577864_Fast_elegant_switchcaselike/recipe-577864.py