Efficient mechanism for str.startswith on a set.

Paul Rubin http
Tue Jan 10 09:52:01 EST 2006


Brian Cole <brianc at temple.edu> writes:
> This is obviously the least efficient manner to do this as I'll always
> be iterating over the entire 'strs'. I know I could make a binary tree
> out of 'strs' but that's a little more work that don't have time to do
> today. I know there should be something out there if I just ask nicely
> enough.

This may be overkill but it's the right approach in principle:

http://osteele.com/software/python/fsa/



More information about the Python-list mailing list