diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py index f66ddde4adb..59aea99d5e6 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py @@ -687,6 +687,7 @@ def should_generate_more(): ): initial_calls = self.call_count failed_mutations = 0 + groups = None while ( should_generate_more() # We implement fairly conservative checks for how long we @@ -695,11 +696,12 @@ def should_generate_more(): and self.call_count <= initial_calls + 5 and failed_mutations <= 5 ): - groups = defaultdict(list) - for ex in data.examples: - groups[ex.label, ex.depth].append(ex) + if groups is None: + groups = defaultdict(list) + for ex in data.examples: + groups[ex.label, ex.depth].append(ex) - groups = [v for v in groups.values() if len(v) > 1] + groups = [v for v in groups.values() if len(v) > 1] if not groups: break @@ -750,6 +752,7 @@ def should_generate_more(): ) ): data = new_data + groups = None failed_mutations = 0 else: failed_mutations += 1