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

Efficient strategy for st.text(...).filter(str.isidentifier) #3480

Closed
Zac-HD opened this issue Oct 17, 2022 · 1 comment
Closed

Efficient strategy for st.text(...).filter(str.isidentifier) #3480

Zac-HD opened this issue Oct 17, 2022 · 1 comment
Labels
enhancement it's not broken, but we want it to be better performance go faster! use less memory!

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Oct 17, 2022

As a follow-up to #2693 (comment) and #3134, I'd like to return an efficient strategy for st.text(...).filter(str.isidentifier).

Adapting https://github.com/Zac-HD/hypothesmith/blob/85358991f8498db489569e81ac9dc9049c75773f/src/hypothesmith/syntactic.py#L39-L56 should make this pretty easy, even with the slight complication of incorporating the restrictions of the alphabet= strategy.

We could optionally add similar support for the other str.isX methods, which mostly impose simpler constraints and could be satisfied more efficiently by replacing the self.elements strategy (e.g. str.isspace requires all-whitespace chars), and for some adding the filter on at the end (e.g. str.isupper is satisfied if all cased characters in the string are uppercase and there is at least one cased character).

Note that st.characters().filter(...) will often be considerably simpler; we can compute and cache the allowed characters directly - although often more quickly than by naive iteration, if we're willing to spend some code on it.

@Zac-HD Zac-HD added enhancement it's not broken, but we want it to be better performance go faster! use less memory! labels Oct 17, 2022
@Zac-HD
Copy link
Member Author

Zac-HD commented Sep 17, 2023

Closed in #3725 🎉

@Zac-HD Zac-HD closed this as completed Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement it's not broken, but we want it to be better performance go faster! use less memory!
Projects
None yet
Development

No branches or pull requests

1 participant