Skip to content

Refactor - remove re._compile? #122358

Open
Open
@wimglenn

Description

@wimglenn

Feature or enhancement

Proposal:

Here is re.compile:

>>> import re, inspect
>>> print(inspect.getsource(re.compile))
def compile(pattern, flags=0):
    "Compile a regular expression pattern, returning a Pattern object."
    return _compile(pattern, flags)

It just calls re._compile with the same arguments.

When it was introduced it looked like there was some benefit to having an "implementation hook" to swap in impl from sre_compile.py.

I think the benefit doesn't really exist anymore - it seems like there should be a slight performance improvement, and simpler tracebacks, to just move the body of _compile directly into compile.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-regextype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions