【发布时间】:2012-08-28 00:10:53
【问题描述】:
我在堆栈溢出中阅读了很多比较子字符串搜索性能的帖子(例如Python string search efficiency, Is this the most efficient way to search for a substring?, substring in python等...)
我还查看了 contains abstract.c 的源代码实现。
据我所知,内置实现是一个迭代的:python docs
python 是否有实现更充分的技术来查找子字符串:Boyer–Moore Algorithm, Rabin–Karp algorithm等... ???
编辑
问题已扩展: Python: Improving sub-string search by embedding sophisticated algorithms.
【问题讨论】:
-
+1 将其与 Rabin-Karp 进行比较会很有趣
-
@Martijn Pieters:请注意,在您添加指向 string_contains 的链接之前,我已经问过这个问题。
-
@Martijn Pieters:似乎对于 python 2.7 fastsearch 没有实现 Boyer–Moore (hg.python.org/cpython/file/2370e331241b/Objects/stringlib/…),我错了吗???
-
最好提出一个新问题,而不是改变已经回答的旧问题的前提。 :-)
标签: python c performance algorithm substring