What algorithm does Python use to evaluate: if substring in string

Fredrik Lundh fredrik at pythonware.com
Mon Sep 11 12:45:52 CEST 2006

"Tor Erik" wrote:

> I would be surprised if it is the naive:

2.4 and earlier uses that algorithm (but with a better implementation).

And "naive" isn't really the right word here; on average, a brute force search is pretty
good for the find/index/in use case.  Most fancy algorithms ignore the setup costs and
other overhead, which works well in theory, but not that well in practice.


More information about the Python-list mailing list