def insert_with_prefixes(key, value, dict_):
    prefixes = (key[:i + 1] for i in range(len(key)))
dict_.update((prefix, value) for prefix in prefixes)
fastest way to search python dict with partial keyword