【问题标题】:What is the algorithm behind re.finditer? [closed]re.finditer 背后的算法是什么? [关闭]
【发布时间】:2020-09-10 04:22:50
【问题描述】:

我正在研究字符串搜索算法,经过几次时间后,我发现与我的 Naive/KMP/Boyer-Moore 实现相比,re.finditer 函数的结果要快得多。我读到 Python re libray 使用基本的回溯算法,但我想知道是否有人可以指出我可以尝试更好地理解他们的算法的更具体的方向/代码?谢谢!

【问题讨论】:

    标签: algorithm pattern-matching python-re


    【解决方案1】:

    解决方案

    假设您指的是 CPython。

    函数在这里定义: https://github.com/python/cpython/blob/master/Lib/re.py#L243-L248

    回溯算法在这里实现:https://github.com/python/cpython/blob/master/Lib/sre_compile.py

    【讨论】:

      猜你喜欢
      • 2019-11-14
      • 1970-01-01
      • 2010-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 2012-10-02
      相关资源
      最近更新 更多