-
Notifications
You must be signed in to change notification settings - Fork 588
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 filter-rewriting for st.text(...).filter(str.isidentifier)
#3725
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking on this issue Reagan! I've added some comments around the implementation (I thought of a more efficient way to do it 😅) and tests, but this is already a great start.
hypothesis-python/src/hypothesis/strategies/_internal/strings.py
Outdated
Show resolved
Hide resolved
hypothesis-python/src/hypothesis/strategies/_internal/strings.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase on #3730 to fix merge conflicts and get some nice new helpers, then I think we're nearly there!
hypothesis-python/src/hypothesis/strategies/_internal/strings.py
Outdated
Show resolved
Hide resolved
hypothesis-python/src/hypothesis/strategies/_internal/strings.py
Outdated
Show resolved
Hide resolved
# Should we deterministically check whether ascii or not or st.characters fine? | ||
@pytest.mark.parametrize("al", [None, "cdef123", "cd12¥¦§©"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine to ignore the non-OneCharStringStrategy
case (fyi sampled_from()
is automatically converted in text()
!); definitely good to test both ascii and non-ascii.
st.text(...).filter(str.isidentifier)
a2ca289
to
4d146f5
Compare
Thanks Reagan! This was surprisingly tricky to get working at a low level, but your logic and faster intersection calculation were really useful - and will have a big impact in Zac-HD/hypothesmith#32 very soon 😁 (comment instead of review because github is currently degraded!) |
Implements #3480
Adds more efficient strategy for
st.text(...).filter(str.isidentifier)
. When runningst.text().filter(str.isidentifier)
on 100 iterations,