-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Improve speed of stdlib functions by replacing re uses #130167
Copy link
Copy link
Open
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
We can often find the module
rein the standard library modules but it can be replaced (if it is possible). I don't suggest removing it everywhere, there are places where its use is appropriate, but there are also places where it is an unnecessary solution and leads to unpleasant consequences (they can be found below)Cons of regular expressions and reasons to replace regular expressions with functions and methods:
import rewhich will affect import timeImportant
For those who want to work on the issue, please:
pyperf,hyperfine, andtunatogether with-X importtimeto compare import times and execution time.gh-130167: Improve speed of `module.function` by replacing `re`Linked PRs
difflib.IS_LINE_JUNKby replacingre#130170inspect.formatannotationby replacingre#130242ftplib.parse150by replacingre#130243textwrap.dedent()#131919textwrap.dedent()optimization #131925textwrap.{de,in}dent#131924_pydecimal._all_zerosand_pydecimal._exact_halfby replacingre#132065textwrap.dedent#132666textwrap.{de,in}dent(GH-131924) #143292