Commit 9d77b151 authored by Stefan Behnel's avatar Stefan Behnel

another minor benchmark refactoring

parent cd37bef3
...@@ -31,12 +31,12 @@ def permutations(iterable): ...@@ -31,12 +31,12 @@ def permutations(iterable):
yield [ pool[i] for i in indices ] yield [ pool[i] for i in indices ]
while n: while n:
for i in reversed(range(n)): for i in reversed(range(n)):
cycles[i] -= 1 j = cycles[i] - 1
if cycles[i] == 0: if j == 0:
indices[i:] = indices[i+1:] + indices[i:i+1] indices[i:] = indices[i+1:] + indices[i:i+1]
cycles[i] = n - i cycles[i] = n - i
else: else:
j = cycles[i] cycles[i] = j
indices[i], indices[-j] = indices[-j], indices[i] indices[i], indices[-j] = indices[-j], indices[i]
yield [ pool[i] for i in indices ] yield [ pool[i] for i in indices ]
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment