tags:

views:

146

answers:

3

I was wondering if the 'find' method on strings was implemented with a linear search, or if python did something more sophisticated. The Python documentation doesn't discuss implementation details, so http://docs.python.org/library/stdtypes.html is of no help. Could someone please point me to the relevant source code?

+4  A: 

You should be able to find it in Objects/stringlib/find.h, although the real code is in fastsearch.h.

DNS
+1  A: 

Looks like the algorithm used originates from Boyer-Moore-Horspool algorithm

cartman