Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pre-parsed patterns #18

Closed
jayvdb opened this issue Feb 16, 2020 · 0 comments · Fixed by #19
Closed

Allow pre-parsed patterns #18

jayvdb opened this issue Feb 16, 2020 · 0 comments · Fixed by #19

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Feb 16, 2020

I'm processing ~20,000 patterns, and I would rather not have them parsed/compiled a few times.

So I sre_parse them, and then use sre_compile.compile(p) to create the compiled pattern when needed. re.compile does those two steps anyway - the only difference is whether the compiled regex has the pattern attribute as a string containing the original regex.

The parsed (not compiled) version seems to be more suitable for keeping in memory for longer periods, as its size is more closely related to the string pattern length, while the compiled regex can be 8x the input string size.

jayvdb added a commit to jayvdb/sre_yield that referenced this issue Feb 16, 2020
jayvdb added a commit to jayvdb/sre_yield that referenced this issue Feb 17, 2020
Replaces existing \Z with re.fullmatch, and allows the
input pattern to be a sre_parse.SubPattern.

Closes google#18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant