The algorithm used to implement the str.count Python function

I looked at the Python function str.countwhile reading the documentation. It seems that I can not find a good explanation of the inner workings of the function. What algorithm is used to count the number of substrings in a string? How it works?

+2
source share
1 answer

Check out the source code https://github.com/python/cpython/blob/master/Objects/stringlib/fastsearch.h

The comment at the top of the file explains this:

/ , boyer-moore , . , .: http://effbot.org/zone/stringlib.htm

+5

Source: https://habr.com/ru/post/1662964/


All Articles