Skip to content

Commit

Permalink
Merge pull request #4282 from tybug/target-extend
Browse files Browse the repository at this point in the history
Don't extend during the target phase
  • Loading branch information
tybug authored Mar 4, 2025
2 parents b8117ff + 39d6455 commit bd43b64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch tweaks the performance of the :ref:`target phase <phases>`, avoiding aborting some test cases when it would be better to finish generating them.
15 changes: 4 additions & 11 deletions hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,7 @@ def __init__(

# Because the shrinker is also used to `pareto_optimise` in the target phase,
# we sometimes want to allow extending buffers instead of aborting at the end.
if in_target_phase: # pragma: no cover
# TODO_IR: this is no longer used, but it should be. See
# https://github.com/HypothesisWorks/hypothesis/commit/91c63bb76c970effd6cf3c013d8ed98788cf0527
# we'll need to adjust for the new notion of size in terms of nodes,
# and change self.cached_test_function_ir.
from hypothesis.internal.conjecture.engine import BUFFER_SIZE

self.__extend = BUFFER_SIZE
else:
self.__extend = 0
self.__extend = "full" if in_target_phase else 0
self.should_explain = explain

@derived_value # type: ignore
Expand Down Expand Up @@ -399,7 +390,9 @@ def cached_test_function_ir(self, nodes):
if not choice_permitted(node.value, node.kwargs):
return None

result = self.engine.cached_test_function_ir([n.value for n in nodes])
result = self.engine.cached_test_function_ir(
[n.value for n in nodes], extend=self.__extend
)
self.incorporate_test_data(result)
self.check_calls()
return result
Expand Down

0 comments on commit bd43b64

Please sign in to comment.