One function

random_product in more-itertools/more-itertools

The author described this change as Fix random_product() as well. It counts as a record because the check below fails on the code as it stood at 073d23421 and passes on b0aa91efb, with nothing else changed between the two runs.

Fix saved2025-12-30
Sharing licenceMIT · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Draw an item at random from each of the input iterables. If *repeat* is provided as a keyword argument, that many items will be drawn from each iterable. This equivalent to taking a random selection from `itertools.product(*args, repeat=repeat)`.

The change

1414 ``itertools.product(*args, repeat=repeat)``.
1515
1616 """
17- pools = tuple(map(tuple, iterables * repeat))
17+ pools = tuple(map(tuple, iterables)) * repeat
1818 return tuple(map(choice, pools))

The check that tells the two apart

failpass·tests/test_recipes.py::RandomProductTests::test_list_with_repeat

Check file tests/test_recipes.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it073d23421b60e05a99872e7b174902f4aa151f31
Broken version dated2025-12-30
Modulemore_itertools.recipes
Units changedrandom_product
Fingerprint5e9a38e5b7aa46ce
Checked2026-08-17 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in more-itertools/more-itertools