[ python-Feature Requests-1561634 ] String searching performance improvement

SourceForge.net noreply at sourceforge.net
Wed Sep 20 02:10:36 CEST 2006


Feature Requests item #1561634, was opened at 2006-09-19 12:55
Message generated for change (Settings changed) made by mackstann
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1561634&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Performance
Group: Python 2.6
>Status: Deleted
Resolution: None
Priority: 5
Submitted By: Nick Welch (mackstann)
Assigned to: Nobody/Anonymous (nobody)
Summary: String searching performance improvement

Initial Comment:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1561634&group_id=5470


More information about the Python-bugs-list mailing list