I'm interested in implementing autocomplete in Python. For example, as the user types in a string, I'd like to show the subset of files on disk whose names start with that string.
What's an efficient algorithm for finding strings that match some condition in a large corpus (say a few hundred thousand strings)? Something like:
matches = [s for s in allfiles if s.startswith(input)]
I'd like to have the condition be flexible; eg. instead of a strict startswith, it'd be a match so long as all letters in input appears in s in the same order. What's better than the brute-force method I'm showing here?