python高效的子串搜索

标签 python c performance algorithm substring

<分区>

Possible Duplicate:
How is string.find implemented in CPython?

我在 stack-overflow 中阅读了很多比较子字符串搜索性能的帖子(例如 Python string search efficiencyIs 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 , ETC... ???

编辑

问题已扩展: Python: Improving sub-string search by embedding sophisticated algorithms .

最佳答案

实际的 cpython 字符串搜索实现在这里:

http://hg.python.org/cpython/file/tip/Objects/stringlib/fastsearch.h

它似乎使用了 Boyer-Moore。

关于python高效的子串搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12244754/

相关文章:

python - 多对多表和初始化字段

c - 文件描述符未在 exec 上关闭

java - Java 中的正则表达式及其与 indexOf 相比的性能

使用回溯的随机遍历 N * M 网格的复杂性

c++ - 使用 c 更新文件

sql - 从 PostgreSQL DB 查询时间戳的最大值

php - MySQL - 在一对多关系中选择不匹配的数据

python - 使用 BeautifulSoup 查找与特定关键字相关的链接

python - os.walk 目录名中的空列表是什么?

python - 在 while 循环中以 "trigger"的形式从列表中删除项目