[issue47152] Reorganize the re module sources

Serhiy Storchaka report at bugs.python.org
Sat Apr 2 12:05:08 EDT 2022


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

> Is the "import _locale" still used in re/__init__.py? It cannot see any reference to it in the code and test_re still if it's removed.

It is true.

> *Maybe* it's time to consider that re.template() and re.Scanner are no longer experimental? Maybe change their status to alpha or beta? :-D

First we need to find original discussions for these features (it may be not easy) and decide whether we want to finish them or remove.

> In `Modules` folder, there are _sre.c/sre.h/sre_constants.h/sre_lib.h files. Will them be put into a folder?

It is step 2.

> would it be possible to expose `parse_template` -- or at least some way to validate that a regex replacement string is correct prior to executing the replacement?

Maybe, in some form. Currently you can precompile a pattern, but for a replacement string you rely on a LRU cache. It is slower, and limited by the fixed size of the cache. I think it would be worth to add a function for compiling a replacement string. sub() etc should accept both string and a precompiled template object. It is a separate issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47152>
_______________________________________


More information about the Python-bugs-list mailing list