可能性の重複:私は部分文字列検索のパフォーマンスを比較し、スタックオーバーフローここで多くの記事を読みました
How is string.find implemented in CPython?pythonの効率的な部分文字列検索
(例えばPython string search efficiency、 Is this the most efficient way to search for a substring?、 substring in pythonなど)
また、ソースc odeの実装にはabstract.cが含まれています。私の知る限り、内蔵の実装を参照として
は反復いずれかです。python docs
は、Pythonの部分文字列を見つけるためのより十分な技術の実装を持っている:Boyer–Moore Algorithm、 Rabin–Karp algorithm、等... ? ?
EDIT
は、問題が拡張されました: Python: Improving sub-string search by embedding sophisticated algorithms。
rel:http://stackoverflow.com/questions/681649/how-is-string-find-implemented-in-cpython – georg
+1 Rabin-Karpと比較すると面白いです。 – Michael
@Martijn Pieters:notice string_containsへのリンクを追加する前に私はこの質問をしました。 – Michael