Replies: 1 comment
-
Don't these sorts of algorithms typically require building up a trie/suffix-tree or other pre-work? I'd worry that that would be much more expensive than the naive approach, especially for If there was some method like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When calling the
startswith()
orendswith()
method of astr
object with a tuple of strings, we should use an algorithm that's better suited to match multiple strings in parallel rather than iterating over that tuple and checking for every since entry.One such algorithm is the Teddy algorithm, used by the Hyperscan regex library, and Rust's aho-corasick crate. This algorithm exploits vector instructions to match multiple strings in parallel and is able to yield great performance when compared to the linear, scalar version.
Beta Was this translation helpful? Give feedback.
All reactions