That's my current situation:

* I have a 2.5MB text file with around 250k strings, sorted alphabetically
* Each string is unique
* I don't need to modify the entries in the text file: once the text file is loaded, it is never edited
* The text file is loaded at start and then I just need to search for strings through it

The last point is the problem. Actually I need to search for complete match AND for partial match of the string. The algorithm I wrote just involved the use of regular expressions combined with some attempts to make the process faster: for example, I hardcoded into my script the indexes of the dictionary that identified the singular letters of the alphabet, and then split the big text file fictionary into 26 smaller dictionary. 
That was totally useless, the script is still incredibly slow.
Skimming some posts here, I was convinced to try mmap: but it looked useless to find all the partial matches, given a regular expression.
Eventually I came to the conclusion that a trie may solve my problem, though i hardly know what is this. Should I go with tries? If so, how should I proceed to the creation of a trie in python? [Is marisa-trie module good?](https://github.com/kmike/marisa-trie) Thanks to everybody

EDIT: By "partial match", I mean that I have the prefix of a string. I do not need matches at the end or in the middle, just at the beginning.