First, I\'m new to Python, so I apologize if I\'ve overlooked something, but I would like to use dict.fromkeys
(or something similar) to create a dictionary of
Check out defaultdict (requires Python 2.5 or greater).
from collections import defaultdict
def benchmark(input):
...
return time_taken
runs = 10
inputs = (1, 2, 3, 5, 8, 13, 21, 34, 55)
results = defaultdict(list) # Creates a dict where the default value for any key is an empty list
for run in range(0, runs):
for i in inputs:
results[i].append(benchmark(i))