substring search api

Justin Bailey jgbailey at gmail.com
Tue Sep 18 14:22:49 EDT 2007


On 9/18/07, Johannes Waldmann <waldmann at imn.htwk-leipzig.de> wrote:
> but what for? In a real application, I guess you want to do some further
> processing, so the index is just some intermediate result
> (you will acccess the string via the index later).
>

Actually, sometimes I needed the string from the beginning of the
search to the match point (in which case the tuple would do what I
wanted). In other cases, I needed to know the length of the matched
string. In that case, knowing the index of the match made it very fast
to calculate the length without looking at the string.

While the length of a strict bytestring is very cheap (O(1)), the
length of a lazy bytestring is not. Being able to do the above
optimization was important to my application.

Justin


More information about the Libraries mailing list