Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eensy-weensy teeny toy_multisplit optimization.
For every position in the string, we shave off a substring of the longest possible separator. Then we clip off progressively shorter substrings, until we find a substring that matches one of the separators of that length. If the string doesn't start with any separator, we'll try 'em all. I happen to know that CPython has some hacks that speed up string manipulation. If you only have one reference to a string, and you transform the string somehow and overwrite your reference with the transformed verison, CPython can often simply modify your existing string in-place. So, I rewrote toy_multisplit so it pre-creates the transformed string, then shaves characters off *that*. And it does appear to be a teeny tiny bit faster.
- Loading branch information