This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: String searching performance improvement
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mackstann
Priority: normal Keywords:

Created on 2006-09-19 17:55 by mackstann, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (1)
msg54903 - (view) Author: Nick Welch (mackstann) Date: 2006-09-19 17:55
The current string searching (str.find) seems to use
the simplest possible method of searching, which is
simply comparing character by character.  A simple
speed improvement would be to take needle[-1] and start
searching at haystack[len(needle)-1].  Then check again
at haystack[len(needle)*2-1].  etc.  If the last
character doesn't match, then the rest of the string
couldn't possibly match.  I'm sure there are other
methods of speeding up string searching but this seems
like a pretty simple and easy improvement.  If I have
some time I will go ahead and try implementing it myself.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 43995
2006-09-19 17:55:37mackstanncreate