蟒蛇有效的字符串搜索 [英] python efficient substring search
问题描述
可能重复:
如何在CPython的是string.find实现?
我在比较子字符串搜索的性能堆栈溢出看了很多帖子在这里(如的Python字符串搜索效率, <一href="http://stackoverflow.com/questions/7164711/is-this-the-most-efficient-way-to-search-for-a-substring">Is这是最有效的方式来搜索一个子?中, 在python 子,等...)
I have read many posts here in stack-overflow comparing the performance of sub-string search (e.g. Python string search efficiency, Is this the most efficient way to search for a substring?, substring in python, etc...)
我也看了源$ C $ C实现包含的 abstract.c 。
I have also looked at the source code implementation of contains abstract.c.
据我看到内置的实现是一个迭代:的 python文档
As far as i see the built-in implementation is an iterative one : python docs
巨蟒是否有更充分的技术实现查找字符串: Boyer- Moore算法, 拉宾,卡普算法,等... ???
Does python have an implementation of more sufficient techniques for finding a substring: Boyer–Moore Algorithm, Rabin–Karp algorithm, etc... ???
修改
这个问题已经扩展: <一href="http://stackoverflow.com/questions/12258847/python-2-7-improving-sub-string-search-by-using-sophisticated-algorithms">Python:通过嵌入复杂的算法的提高子字符串搜索。
The question has been extended: Python: Improving sub-string search by embedding sophisticated algorithms.
推荐答案
实际CPython的字符串搜索的实现是在这里:
The actual cpython string search implementation is here:
<一个href="http://hg.python.org/cpython/file/tip/Objects/stringlib/fastsearch.h">http://hg.python.org/cpython/file/tip/Objects/stringlib/fastsearch.h
这似乎使用博耶 - 穆尔。
It appears to use Boyer-Moore.
这篇关于蟒蛇有效的字符串搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!