[issue7462] Implement fastsearch algorithm for rfind/rindex
Florent Xicluna
report at bugs.python.org
Thu Dec 31 11:03:46 CET 2009
Florent Xicluna <laxyf at yahoo.fr> added the comment:
I checked the code, and it is the right thing:
Example 1 (fastsearch):
s, p = "ABCDEABCF", "BCD"
s.rfind(p)
# i = 6 is first candidate, but "BCF" != "BCD"
# then s[i-1] = "A" is not part of pattern
# so we skip 3 chars: next loop is i = 2
# etc...
Example 2 (msg97039):
s, p = "ABCDBCBCF", "BCB"
s.rfind(p)
# i = 6 is first candidate, but "BCF" != "BCB"
# then s[i-m] = "D" is not part of pattern
# so we skip 3 chars: next loop is i = 2.. and it fails!
I've tested many examples to understand and verify the algorithm.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7462>
_______________________________________
More information about the Python-bugs-list
mailing list