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

Please add a warning that Re.Str is not thread safe #194

Open
edwintorok opened this issue Jul 26, 2021 · 2 comments
Open

Please add a warning that Re.Str is not thread safe #194

edwintorok opened this issue Jul 26, 2021 · 2 comments

Comments

@edwintorok
Copy link
Contributor

Like Str itself, Re.Str is not thread safe as it relies on global internal state.
Initially I thought that Re.Str might be thread safe (e.g. if you only use functions like global_replace), but looking at the implementation it is not.

It might be useful to have a variant of Re that provides an Str compatible syntax, but a thread-safe interface (the current Str interface is not thread safe because querying match groups doesn't take the match result as a parameter), but meanwhile a warning in the documentation would be nice.

@rgrinberg
Copy link
Member

I suppose we could have Re.Str.compile that produces Re.re. Is that what you have in mind?

@edwintorok
Copy link
Contributor Author

yes, some way to access the equivalent of the re field from the regexp type.
(I was going to say the mtch or srch fields, but those use Lazy, which is again not thread safe).

Although looking at the implementation, it just calls Emacs.re, but should that change in the future (e.g. the Emacs regex gains some additional syntax that is incompatible with Str), an Str.re would be useful.

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

No branches or pull requests

2 participants