On Oct 1, 2017, at 22:34, Nathaniel Smith <n...@pobox.com> wrote: > > In principle re.compile() itself could be made lazy -- return a > regular exception object that just holds the string, and then compiles > and caches it the first time it's used. Might be tricky to do in a > backwards compatibility way if it moves detection of invalid regexes > from compile time to use time, but it could be an opt-in flag.
I already tried that experiment. 1) there are tricky corner cases; 2) nobody liked the change in semantics when re.compile() was made lazy. https://bugs.python.org/issue31580 https://github.com/python/cpython/pull/3755 I think there are opportunities for an explicit API for lazy compilation of regular expressions, but I’m skeptical of the adoption curve making it worthwhile. But maybe I’m wrong! -Barry
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com