re.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码
def _compile(pattern, flags):
    # internal: compile pattern
    bypass_cache = flags & DEBUG
    if not bypass_cache:
        try:
            return _cache[type(pattern), pattern, flags]
        except KeyError:
            pass
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError(
                "Cannot process flags argument with a compiled pattern")
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError("first argument must be string or compiled pattern")
    p = sre_compile.compile(pattern, flags)
    if not bypass_cache:
        if len(_cache) >= _MAXCACHE:
            _cache.clear()
        _cache[type(pattern), pattern, flags] = p
    return p
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号