HypothesisWorks / hypothesis

Hypothesis is a powerful, flexible, and easy to use library for property-based testing.

Home Page:https://hypothesis.works

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Small optimization in `find_annotated_strategy`

Viicos opened this issue · comments

Currently working on the Pydantic hypothesis plugin, figured the following could be optimized a bit:

for constraint in _get_constraints(metadata):
if convert := get_constraints_filter_map().get(type(constraint)):
filter_conditions.append(convert(constraint))
else:
unsupported.append(constraint)

By building the filter map once before the for loop. If you agree, PR ready to be pushed.

Yes please!